Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On Windows this is a little bit tricky. Actually the distinction between a console application and a GUI one is a single flag in the PE header. You can easily write console applications that create windows but that way you always have the console window around (you could hide it, though, but that wouldn't be nice when people run your program from <code>cmd</code>).</p> <p>You <em>can,</em> however write a GUI application that creates a console if it needs to, using the <a href="http://msdn.microsoft.com/en-us/library/ms681944.aspx" rel="nofollow noreferrer"><code>AllocConsole</code></a> function:</p> <blockquote> <p>A process can be associated with only one console, so the <strong>AllocConsole</strong> function fails if the calling process already has a console. A process can use the <a href="http://msdn.microsoft.com/en-us/library/ms683150(VS.85).aspx" rel="nofollow noreferrer"><strong>FreeConsole</strong></a> function to detach itself from its current console, then it can call <strong>AllocConsole</strong> to create a new console or <a href="http://msdn.microsoft.com/en-us/library/ms681952(VS.85).aspx" rel="nofollow noreferrer"><strong>AttachConsole</strong></a> to attach to another console.</p> <p>If the calling process creates a child process, the child inherits the new console.</p> <p><strong>AllocConsole</strong> initializes standard input, standard output, and standard error handles for the new console. The standard input handle is a handle to the console's input buffer, and the standard output and standard error handles are handles to the console's screen buffer. To retrieve these handles, use the <a href="http://msdn.microsoft.com/en-us/library/ms683231(VS.85).aspx" rel="nofollow noreferrer"><strong>GetStdHandle</strong></a> function.</p> <p>This function is primarily used by graphical user interface (GUI) application to create a console window. GUI applications are initialized without a console. Console applications are initialized with a console, unless they are created as detached processes (by calling the <a href="http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx" rel="nofollow noreferrer"><strong>CreateProcess</strong></a> function with the DETACHED_PROCESS flag).</p> </blockquote> <p>However, when run from <code>cmd</code> this will likely cause another console window to appear instead of re-using the existing one. I don't know whether a good solution exists there.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload