Try to build PDB files even for releases.
[nssm.git] / console.cpp
1 #include "nssm.h"\r
2 \r
3 /* See if we were launched from a console window. */\r
4 bool check_console() {\r
5   /* If we're running in a service context there will be no console window. */\r
6   HWND console = GetConsoleWindow();\r
7   if (! console) return false;\r
8 \r
9   unsigned long pid;\r
10   if (! GetWindowThreadProcessId(console, &pid)) return false;\r
11 \r
12   /*\r
13     If the process associated with the console window handle is the same as\r
14     this process, we were not launched from an existing console.  The user\r
15     probably double-clicked our executable.\r
16   */\r
17   if (GetCurrentProcessId() != pid) return true;\r
18 \r
19   /* We close our new console so that subsequent messages appear in a popup. */\r
20   FreeConsole();\r
21   return false;\r
22 }\r
23 \r
24 void alloc_console(nssm_service_t *service) {\r
25   if (service->no_console) return;\r
26 \r
27   AllocConsole();\r
28 }\r