VST3 resource file path

I’m having issue reading the file path of the VST3 dll, to work out the path of the resource folder (in Windows). I’ve tried both the global gPath defined in dllmain.cpp, or with the snippet (to the debug output, which is pretty much what is dllmain.cpp):
char path[2048];
GetModuleFileName(GetModuleHandle(NULL), (LPWSTR)path, 2048);
sprintf(dbg_buf, “cannot open configuration file \n”);
OutputDebugStringA((LPCSTR)dbg_buf);
OutputDebugStringA((LPCSTR)path);

Both the output of this code or gPath is a simple “C” string, which is certainly not where the plugin dll is stored.

I’m wondering if anybody else had similar issues.

It’s a good idea to avoid using C-casts in C++ code, as the compiler would have alerted you to any potential errors. And in this case the GetModuleFileName will fill the buffer you provide with an UTF-16 encoded string instead of ASCII. Try to change the type of your path variable to wchar_t. And use OutputDebugStringW instead of OutputDebugStringA to print that variable.

Thanks Arne, bad idea indeed. Using the wchar_t and OutputDebugStringW fixed it.

I do however, get the path to the host executable rather then the dll, but I can live with that for my application.

Also gPath returns the expected path to the dll.