3880
社区成员
wchar_t* szStr = L"hello";
hr = pVoice->Speak(szStr, 0, NULL);
或者
wstring wsStr = L"hello";
hr = pVoice->Speak(wsStr.c_str(), 0, NULL);
都行。
如果你拿到的是string类型,那你需要先将string类型转换成wstring类型,转换方法(我懒得写了,从百度找了一个)
std::wstring StringToWString(const std::string& s)
{
std::wstring wszStr;
int nLength = MultiByteToWideChar( CP_ACP, 0, s.c_str(), -1, NULL, NULL );
wszStr.resize(nLength);
LPWSTR lpwszStr = new wchar_t[nLength];
MultiByteToWideChar( CP_ACP, 0, s.c_str(), -1, lpwszStr, nLength );
wszStr = lpwszStr;
delete [] lpwszStr;
return wszStr;
}