請看看下面的代碼無法打開包含文件:「atlbase.h」:沒有這樣的文件或目錄
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override something,
//but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
#include <sapi.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
cout << "Hello" << endl;
ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if(SUCCEEDED(hr))
{
cout << "Succeeded" << endl;
hr = pVoice->Speak(L"Hello world", 0, NULL);
pVoice->Release();
pVoice = NULL;
}
else
{
cout << "Not succeeded" << endl;
}
::CoUninitialize();
return TRUE;
}
我使用QT。當我運行這段代碼,我得到的錯誤
Cannot open include file: 'atlbase.h': No such file or directory
我注意到,我沒有這些文件在我的機器atlbase.h
或atlcom.h
。但是,這段代碼在我的筆記本電腦上運行時沒有出現錯誤,我在那裏找到了那兩個文件
我正在考慮將這兩個文件的副本放到我的臺式計算機上,它會起作用嗎?如果是,我必須複製到哪個文件夾?請注意我是Windows編程,QT和演講的新手。
請幫忙!
您在筆記本電腦上找到的目錄是相同的目錄:) – 2013-05-06 17:58:22
那就是問題所在。目錄是VS 2010專業版。我猜我有1個許可證。 – 2013-05-06 18:06:30
參見:http://stackoverflow.com/questions/3898287/c-include-atlbase-h-is-not-found – 2013-05-06 18:07:51