// 10.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "sapi.h"
#include "sphelper.h"
#pragma comment(lib, "sapi.lib")
#include
#pragma comment(lib,"ole32.lib") //CoInitialize CoCreateInstance需要调用ole32.dll
#pragma comment(lib,"sapi.lib") //sapi.lib在SDK的lib目录,必需正确配置
int main()
{
ISpVoice * pVoice = NULL;
//COM初始化:
if (FAILED (::CoInitialize(NULL)) )
return FALSE;
//获取ISpVoice接口:
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr) )
{
hr = pVoice->Speak(L"asdddffdfd", 0, NULL);
pVoice->Release();
pVoice = NULL;
}
//千万不要忘记:
::CoUninitialize();
return TRUE;
}