0

I'm converting a VS2015 C++ directx/winforms app to VS code using mingw G++ (both on windows 10).

I have it compiling and linking after adding the -mwindows option (and a whole bunch of libraries) but upon stepping into the WinMain there is no value in hInstance.

#include <objbase.h>
#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    LoadString(hInstance, IDS_APP_TITLE,g_szAppName, MAX_LOADSTRING);
...

Which results in anything depending on it like LoadString or RegisterClassEx not working.

What should I be looking for?

Walter ZAMBOTTI
  • 301
  • 1
  • 2
  • 10
  • I'm not sure what *"no value in hInstance"* is supposed to mean but you can always get executable handle by calling `GetModuleHandle` with `NULL`. – user7860670 Jul 04 '18 at 20:19
  • The value of hInstance in the g++ version when compared to vs2015 version – Walter ZAMBOTTI Jul 05 '18 at 01:29
  • Disregard. It wasn't the problem. But what I meant was. The value of hInstance in the g++ version was a suspicious and same round number 0x040000 compared to vs2015 version which was random and different number on each invocation. However this turned out to be the difference between a g++ 32 bit and vs 64 bit. I compared the hInstance value to another working example I downloaded and it too got the same hinstance value and has no trouble creating windows. The actual problem will be in another thread. – Walter ZAMBOTTI Jul 05 '18 at 01:35
  • The actual problem turned out to be compiling the rc file with windres. – Walter ZAMBOTTI Jul 05 '18 at 01:37

0 Answers0