Use the CT2CW conversion class, like this one FuncTakingLPCWSTR(CT2CW(cstring_var)). This is guaranteed to work either in Unicode or in MBCS builds.
Also, keep in mind that the string passed to the function may be temporary, so do not save it for future reference.
source
share