welcher Stringtyp bei pVoice->Speak(string, ...)
-
Welcher Stringtyp bei pVoice->Speak(string, ...)
Verwendet man CString erhält man eine Fehlermeldung.
Erwarteter Typ: const unsigned short *
-
HRESULT AnsiStrToBStr(LPCSTR szAnsiIn, BSTR * lpBstrOut) { DWORD dwSize; if (lpBstrOut == NULL) return E_INVALIDARG; if (szAnsiIn == NULL) { *lpBstrOut = NULL; return NOERROR; } // Get the number of unicode characters needed to convert szAnsiIn... dwSize = MultiByteToWideChar(CP_ACP, 0, szAnsiIn, -1, NULL, 0); if (dwSize == 0) return HRESULT_FROM_WIN32( GetLastError() ); // Allocate a BSTR of the required length... // Note we minus one as SysAllocString takes the length // of the string not including the null terminator while // dwSize includes space for the null terminator. *lpBstrOut = SysAllocStringLen(NULL, dwSize - 1); if (*lpBstrOut == NULL) return E_OUTOFMEMORY; // Convert szAnsiIn into the BSTR we allocated... if ( !MultiByteToWideChar(CP_ACP, 0, szAnsiIn, -1, *lpBstrOut, dwSize) ) { SysFreeString(*lpBstrOut); return HRESULT_FROM_WIN32( GetLastError() ); } return NOERROR; }