开发者

How do I compile a C++ project with "DOS EXE" header flag == false?

I have a VS2010 C++ exe project that I want to compile so that the "DOS EXE" flag in the exe's header is set to false. This is (hopefully) to avoid the creation of a CONHOST.exe when the executable is run. The exe does not have a UI.

At the moment, I am calling ::FreeConsole on startup, to get rid of the CON开发者_运维知识库HOST.exe process, but would prefer it if the CONHOST.exe were never created in the first place.

How can I do this?

Further to the selected answer, I 'fixed up' my code by adding a WinMain that calls through to the existing main, as follows:

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
  int argc;
  LPWSTR* argv = CommandLineToArgvW(pCmdLine, &argc);
  _tmain(argc, argv);
  LocalFree(argv);
}


You can try to change SubSystem value in linker options from CONSOLE to WINDOWS. This will prevent compiler from generating console-supporting code in the binary. Note that you will need to use WinMain() function instead of main()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜