How can we prevent console windows from being displayed under Visual Studio?
Is it possible (and开发者_如何学Go how) to disable the display of the Console window when we launch an application under Visual Studio?
EDIT:
Some precisions:
I have at the beginning of this project no GUI system. In a second time I have added QT gui to this project. Currently when I launch my application, I have the console system and the QT's MainWindow
I would like to disable console system
You will have to use just an application and not a console application. To do that:
Change SubSystem to Windows. You can find it under:
Properties ---> Linker ---> System
and replace
int _tmain(int argc, _TCHAR* argv[])
with
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
You cannot (but see below) and this has nothing to do with Visual Studio, but with how Windows differentiates Console and "non Console" applications.
A console application has some kind of flag set in it's executable so that Windows knows that it's a CLI and Windows will then always open up a console and attach it to this process.
A GUI app doesn't have this flag and therefore Windows will not attach a console (and when run from the Windows cmd.exe shell, the shell won't attach to this app either.)
You can control Console attaching and detaching from your app with the AllocConsole
and FreeConsole
Windows API functions, but what you really want to do is probably what Als describes in his answer.
If it is a windows application then yes - you control the UI. If it is a console application then you get a console with stdin, stdout, etc. If you are looking for something with no UI at all then maybe a Windows Service is what you are after.
精彩评论