AllocConsole

  BOOL AllocConsole(VOID)    

The AllocConsole function allocates a new console for the current process.

Parameters

This function has no parameters.

Return Value

The return value is TRUE if the function was successful. Otherwise it is FALSE. Use the GetLastError function to obtain extended error information.

Comments

This function creates a console for the current process. It also sets up standard input, output, and error handles. If the current process already has a console, AllocConsole will fail unless the initial console is first freed with FreeConsole. If the current process creates a child process, the child will inherit the new console.

Handles to the input and output buffers of the newly allocated console can be obtained with the GetStdHandle function.

This function is primarily used by graphics applications that want to create a console window. Graphics applications are initialized without a console. Console applications are normally initialized with a console unless they are created as detached processes (by calling CreateProcess with the DETACHED_PROCESS flag).

See Also

FreeConsole, GetStdHandle