I was trying to make a application.
i want that application to run as process (no console window)
but i can not hide it completely.
when i use FreeConsole() it hides the window but it shows the console in beginning
like a micro second popup which i don't want.
any other way to hide the console window completely.
If you don't want the console, don't create a console program. In Visual Studio, start a new project, expand the left treeview node "Visual C++", then select the Win32 subnode. To the right, select Win32 Project.
Now give it a name, then click OK. A tiny 2-step wizard appears. Move to the next page, select "Windows application" and "Empty project".
Now you're in good shape. Just add a new CPP file and write the entry point:
1 2 3 4 5 6 7 8 9 10 11 12
//Define the minimum operating system for the application:
#define _WIN32_WINNT _WIN32_WINNT_WINXP //Windows XP
//Get rid of the annoying min() and max() macros:
#define NOMINMAX
//Include the windows header:
#include <windows.h>
//Now write the entry point. It is the 21st century, so write Unicode programs. This is the Unicode entry point.
int wWinMain(HINSTANCE hInst, HINSTANCE prevInst, LPWSTR szCmdLine, int nCmdShow)
{
//Your code here.
}
If you use some other IDE different than Visual Studio, then I don't know how to change the project type, or even if the concept of "project" exists in it. Sorry.
In a way #define NOMINMAX is completely unnecessary for this post, but in another way it is VERY nessesary. I hate those macros. For that reason, every-time I create a new module in this crazy project that includes windows.h in the pre-compiled header I almost always add:
1 2 3 4 5 6 7 8 9 10 11 12
#ifdef min
#undef min
#endif
#ifdef max
#undef max
#endif
namespace myNamespace
{
template<class T> T min(T a, T b) { return (a<b)? a : b; }
template<class T> T max(T a, T b) { return (a<b)? a : b; }
}
Open Code::Blocks, Open your Project, Right click the Project Name in the Files tab (Management), and click Properties.
Go in the "Build Targets" Tab, and choose Debug or Release, depending on how you compile the program (Probably Debug), and under the "Type" List Box, choose "GUI Application". Click OK.
You need to do it on every project you want to hide the console window on.