Detect if we were double-clicked.
authorIain Patterson <me@iain.cx>
Sun, 29 Dec 2013 17:29:21 +0000 (17:29 +0000)
committerIain Patterson <me@iain.cx>
Sun, 29 Dec 2013 18:00:59 +0000 (18:00 +0000)
Because we are compiled as a console subsystem application, if the user
double-clicks the executable it will pop up a new console window.  Then,
since no arguments were passed, we will dump a usage message which the
user won't have time to read, and exit.

We now detect this situation and redirect the usage message to a popup.

There are three likely cases to handle.

If we are running in a service context there won't be a console window.
GetConsoleWindow() will return a null handle.

If were launched from a command window, the process ID owning the
console handle will be different from as our process ID.

If the process IDs are the same, we were started with a new console.  We
call FreeConsole() to close it and subsequently direct the usage message
to a message box.


No differences found