#include <windows.h>\r
#include <stdlib.h>\r
#include <string.h>\r
+#include <stdio.h>\r
\r
extern int smain(int argc, char** argv);\r
\r
\r
scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);\r
if (!scm)\r
+ {\r
+ printf("Unable to open service control manager: %d\n", GetLastError());\r
return;\r
+ }\r
\r
- myService = CreateService(scm,"InspIRCd","Inspire IRC Daemon", SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, modname, 0, 0, 0, 0, 0);\r
+ myService = CreateService(scm,"InspIRCd","Inspire IRC Daemon", SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,\r
+ SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, modname, 0, 0, 0, NULL, NULL);\r
\r
if (!myService)\r
{\r
+ printf("Unable to create service: %d\n", GetLastError());\r
CloseServiceHandle(scm);\r
return;\r
}\r
BOOL success = ChangeServiceConf(myService,SERVICE_CONFIG_DESCRIPTION, &svDesc);\r
if (!success)\r
{\r
+ printf("Unable to set service description: %d\n", GetLastError());\r
CloseServiceHandle(myService);\r
CloseServiceHandle(scm);\r
return;\r
FreeLibrary(advapi32);\r
}\r
\r
+ printf("Service installed.\n");\r
CloseServiceHandle(myService);\r
CloseServiceHandle(scm);\r
}\r
\r
scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);\r
if (!scm)\r
+ {\r
+ printf("Unable to open service control manager: %d\n", GetLastError());\r
return;\r
+ }\r
\r
myService = OpenService(scm,"InspIRCd",SERVICE_ALL_ACCESS);\r
if (!myService)\r
{\r
+ printf("Unable to open service: %d\n", GetLastError());\r
CloseServiceHandle(scm);\r
return;\r
}\r
\r
if (!DeleteService(myService))\r
{\r
+ printf("Unable to delete service: %d\n", GetLastError());\r
CloseServiceHandle(myService);\r
CloseServiceHandle(scm);\r
return;\r
}\r
\r
+ printf("Service removed.\n");\r
CloseServiceHandle(myService);\r
CloseServiceHandle(scm);\r
}\r
}\r
\r
/* First, check if the service is installed.\r
- * if it is not, just call smain().\r
+ * if it is not, or we're starting as non-administrator,\r
+ * just call smain() and start as normal non-service\r
+ * process.\r
*/\r
SC_HANDLE myService, scm;\r
scm = OpenSCManager(0,0,SC_MANAGER_CREATE_SERVICE);\r