#include <sapi.h> #pragma comment(lib,"ole32.lib") #pragma comment(lib,"sapi.lib") int main(int argc, char* argv[]) { ISpVoice * pVoice = NULL; if (FAILED(::CoInitialize(NULL))) return FALSE; HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice); if (SUCCEEDED(hr)) { hr = pVoice->Speak(L"您好!请缴费10元", 0, NULL); //Sleep(10); hr = pVoice->Speak(L"您好!请缴费10元", 0, NULL); pVoice->Release(); pVoice = NULL; } ::CoUninitialize(); return TRUE; }
时间: 2024-10-19 06:54:07