Jump to content
  • Advertisement
Sign in to follow this  
shvalb

DirecShow: converting to WCHAR

This topic is 4992 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
Advertisement
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!