I created a Win32 Console application, and hide the cmd window. So if my application is running, it can be seen only by the running processes. If there is a way, i want to modify my applicaition in the following way:
If i define a parameter it should show the cmd window, but if i don’t use this parameter then it should running without showing the cmd window.
I have disabled showing the cmd window the following way:
#pragma comment( linker, "/SUBSYSTEM:WINDOWS" )
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
...
...
...
}
Has anyone an idea how to do this?
kampi
The lpCmdLine parameter to WinMain gives you access to the command-line for the program. You can simply read its value and then take the appropriate action based on its value.
EDIT: The actual mechanics of displaying a console in Windows are a bit tricky. You have to create the console, then redirect the standard output streams to write to it. There’s a great discussion of this here that does a great job detailing how this works and what code you need to get the job done.
Hope this helps!