Menu
  • HOME
  • TAGS

Cannot convert parameter 1 from 'const wchar_t *' to 'LPCTSTR' in MFC / C++ project

c++,string,mfc,tchar,lpcwstr

The easiest way is simply to use MessageBoxW instead of MessageBox. MessageBoxW(e.getAllExceptionStr().c_str(), L"Error initializing the sound player"); The second easiest way is to create a new CString from the original; it will automatically convert to/from wide string and MBCS string as necessary. CString msg = e.getAllExceptionStr().c_str(); MessageBox(msg, _T("Error initializing the...

Expression: string iterators incompatiable, when calling “SetDllDirectory”

c++,wstring,lpcwstr,setdlldirectory

You are calling string_Dir() twice and then using iterators from different std::string objects to initialize your std::wstring. That is why you are getting an incompatibility error. You must use iterators from the same std::string object, so call string_Dir() once and assign the return value to a variable: std::string dir =...

Retrieving VolumeDetails of WINDOWS Drives - stuck with 'char []' to 'LPCWSTR' conversion

windows,winapi,wchar-t,lpcwstr

I see at least these main issues: 1) wchar_t is the right type because you're compiling for UNICODE, you can write generic code using TCHAR macro or explicitly declare your buffer as wchar_t but that's what to do. 2) You have that error because you're passing wrong path to GetVolumeInformation()...