DirecShow: converting to WCHAR
Hi.
I use DirectShow, and the function SetOutputFileName() must receieve a WCHAR as file name. I convert char* to WCHAR using this 2 lines:
nLen = MultiByteToWideChar(CP_ACP, 0, combinedFileName, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, combinedFileName, -1, &OutPutFile, nLen);
It works fine, but the problem is if I need a long file name containing path it fails! any ideas how to resolve this problem ?
That's the only way it works for me, if you have a better way to convert char* to wchar - please share with me.
Thanks.
Thanks.
You must convert from char* to wchar*, not wchar. For example:
My guess is, you were doing this:
Which would overwrite invalid memory.
char mStr[100] = "Hello World";WCHAR wStr[100];MultiByteToWideChar(CP_ACP, 0, mStr, -1, wStr, 100);
My guess is, you were doing this:
WCHAR wStr; //notice this is not an array or pointerMultiByteToWideChar(CP_ACP, 0, mStr, -1, &wChar, nLen);
Which would overwrite invalid memory.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement