AttachConsole() isn't available in Windows 2000.
[nssm.git] / nssm.cpp
index 1ee38bd..0ce8664 100644 (file)
--- a/nssm.cpp
+++ b/nssm.cpp
@@ -2,6 +2,7 @@
 \r
 extern unsigned long tls_index;\r
 extern bool is_admin;\r
+extern imports_t imports;\r
 \r
 /* String function */\r
 int str_equiv(const char *a, const char *b) {\r
@@ -69,6 +70,9 @@ int main(int argc, char **argv) {
     This will save time when running with no arguments from a command prompt.\r
   */\r
   if (_fileno(stdin) < 0) {\r
+    /* Set up function pointers. */\r
+    if (get_imports()) exit(111);\r
+\r
     /* Start service magic */\r
     SERVICE_TABLE_ENTRY table[] = { { NSSM, service_main }, { 0, 0 } };\r
     if (! StartServiceCtrlDispatcher(table)) {\r
@@ -76,6 +80,7 @@ int main(int argc, char **argv) {
       /* User probably ran nssm with no argument */\r
       if (error == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) exit(usage(1));\r
       log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_DISPATCHER_FAILED, error_string(error), 0);\r
+      free_imports();\r
       exit(100);\r
     }\r
   }\r