DirecShow: converting to WCHAR

Started by
2 comments, last by lack o comments 19 years, 2 months ago
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 ?
Advertisement
It looks like you are passing the address of the WCHAR to the function. Why?
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.
You must convert from char* to wchar*, not wchar. For example:
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