iPlug2 Forum

Cannot 'LPTSTR' to 'char *'

Hello guys,

::GetModuleFileName((HINSTANCE)&__ImageBase, strDLLPath1, _MAX_PATH);
ss << “{\n “sum_artifact”: “” << md5.digestFile(strDLLPath1) << “”\n}”;

In VST 2th project looks good but in VST 3th I see this problem Cannot 'LPTSTR' to 'char *’. How to fix this? Thanks.

I haven’t worked on the VST2 distribution and haven’t used the LPTSTR macro/typedef, but I encountered a similar problem with code portability between the standalone app and VST3 build. In the APP project, TCHAR is a typedef for char, so it can be directly converted to a string. In the VST3 project, TCHAR is wchar_t and cannot be automatically converted to std::string. I got around this by converting it the wchar_t array to a wstring, converting that to bytes, and then converting that to a regular string for further use.

As for what solution is best for you - that’s a general C++ issue. The first result on StackOverflow for “convert wchar_t to string” worked for me.

1 Like