From: Iain Patterson Date: Sun, 29 Dec 2013 17:29:21 +0000 (+0000) Subject: Detect if we were double-clicked. X-Git-Tag: v2.22~104 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;ds=sidebyside;h=dd0e555ba889a74ae14487ca0b4a5c62cfa4d873;hp=dd0e555ba889a74ae14487ca0b4a5c62cfa4d873;p=nssm.git Detect if we were double-clicked. 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. ---