Hey, is there any function to convert a char to a WCHAR? I can't get the speach function to work because it wants a WCHAR. I've tried type casting but it doesn't work. I can hard code the file in but i want the user to be able to choose which file they want. To hard code it I have to add an L infront of the quation marks for the text, but how could i do something like this with a normal char?
The code below doesn't compile and gives me the following error:
cannot convert parameter 1 from 'char [255]' to 'const unsigned short *
Code:
#include <sapi.h>
#include <iostream.h>
#include <fstream.h>
int main(int argc, char* argv[])
{
ifstream file;
char string[255];
ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return 0;
cout << "Enter the name of a text file you want spoken: ";
cin >> string;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
hr = pVoice->Speak(string, SPF_IS_FILENAME | SPF_IS_XML, NULL);
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return 0;
}