<分区>
请看下面的代码
#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
。然而,这段代码在我的笔记本电脑上运行没有错误,我在那里得到了那 2 个文件。
我正在考虑将这 2 个文件的拷贝复制到我的台式计算机中,它可以工作吗?如果是,我必须将它们复制到哪个文件夹?我是 Windows 编程、QT 和语音的新手。