MinGW, build GUI application with console

前端 未结 4 1754
情深已故
情深已故 2021-02-02 04:19

I\'m using MinGW to build my application on Windows. When compiling and linking, the option \"-mwindows\" is put in command line to have Win32 API functions.

To be more

4条回答
  •  面向向阳花
    2021-02-02 04:36

    You need to manually capture hInstance and nCmdShow (WinMain arguments). You can use the following C functions to do this:

    HINSTANCE GetHInstance( ) {
       return (HINSTANCE) GetModuleHandleW(NULL);
    }
        
    int GetNCmdShow() {
       STARTUPINFOW startupInfo;
       GetStartupInfoW(&startupInfo);
       if ((startupInfo.dwFlags & STARTF_USESHOWWINDOW) != 0) {
          return startupInfo.wShowWindow;
       }
       return SW_SHOWDEFAULT;
    }
    

提交回复
热议问题