Sign in to follow this  

DirecShow: converting to WCHAR

This topic is 4689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites
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 pointer

MultiByteToWideChar(CP_ACP, 0, mStr, -1, &wChar, nLen);


Which would overwrite invalid memory.


Share this post


Link to post
Share on other sites

This topic is 4689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this