Show Window needs a window handle, so you need a way to get that. FindWindow() is probably not a good way to do that. To get a console apps own window handle use GetConsoleWindow(). I have no idea what AllocConsole() is there for. A process may have only one associated console, and this presumably already has one?
Of course if you simply want to write an app that has no window, simply select the GUI app option, but use the standard main() entry point and do not create or show a window (console or otherwise). At the command line the option that disables a console window for any app (including GUI) is -mwindows, GUI apps use that by default, but you can use it for console apps to, and you can remove it for GUIs to get a console window as well.
I would suggest that you debug and test your code well before hiding its window. And be aware that most users would be suspicious of code that attempts to hide itself from view while executing.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found a code to hide the console(command prompt):
HWND hide;
AllocConsole();
hide=FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(hide, 0);
Could i hide the console with only ShowWindow();? And if yes how and are there any more ways to hide the console.
Thanks in advance.
Why would you ever need more than one way!?
Show Window needs a window handle, so you need a way to get that. FindWindow() is probably not a good way to do that. To get a console apps own window handle use GetConsoleWindow(). I have no idea what AllocConsole() is there for. A process may have only one associated console, and this presumably already has one?
Of course if you simply want to write an app that has no window, simply select the GUI app option, but use the standard main() entry point and do not create or show a window (console or otherwise). At the command line the option that disables a console window for any app (including GUI) is -mwindows, GUI apps use that by default, but you can use it for console apps to, and you can remove it for GUIs to get a console window as well.
I would suggest that you debug and test your code well before hiding its window. And be aware that most users would be suspicious of code that attempts to hide itself from view while executing.
Clifford