Create an Application without a Window

后端 未结 7 1438
一个人的身影
一个人的身影 2020-11-28 09:15

How would you program a C/C++ application that could run without opening a window or console?

7条回答
  •  感动是毒
    2020-11-28 10:10

    In windows:

    #include 
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPTSTR    lpCmdLine,
                         int       nCmdShow)
    {
        // <-- Program logic here
        return 0;
    }   
    

    Be sure to use the /SUBSYSTEM linker switch as mentioned by Adam Mitz.

    On other platforms:

    int main(int argc, char**argv)
    {
      // <-- Program logic here
      return 0;
    }
    

提交回复
热议问题