Replacing WinMain() with main() function in Win32 programs

后端 未结 4 1598
無奈伤痛
無奈伤痛 2020-11-28 04:56

I searched a little bit on StackOverflow and Google but couldn\'t get the idea. I want to start my application with this type of user programming:

int main()         


        
4条回答
  •  清歌不尽
    2020-11-28 05:32

    You can use standard main in a "windows" app (that is, a GUI subsystem Windows application) even with the Microsoft tools, if you add the following to the Microsoft linker options:

    /subsystem:windows /ENTRY:mainCRTStartup
    

    Note that this is not necessary for the GNU toolchain.

    Still for the Microsoft tools you can alternatively add this to your main file:

    #ifdef _MSC_VER
    #    pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
    #endif
    

    @James McNellis tells you how to get the hInstance.

提交回复
热议问题