In MFC, the filename and path you get from a File Open dialog come as a CString.

I wanted to pass that to FMOD’s (http://www.fmod.org)/) createSound function, but its parameter type is char.

For example:

CString name = "d:\path\sound.mp3";
fmodSystem->createSound((LPCTSTR)name, ....);

Trying to open the file and use it in fmod like this obviously throws a casting error.

But changing a Visual Studio project setting makes the error go away.

attached image

Switch that setting to “Use Multi-Byte Character Set” (the default is Unicode).