1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 #ifndef _WINSVC_ 7 #define _WINSVC_ 8 9 #include <_mingw.h> 10 #include <_mingw_unicode.h> 11 12 #ifndef WINADVAPI 13 #ifndef _ADVAPI32_ 14 #define WINADVAPI DECLSPEC_IMPORT 15 #else 16 #define WINADVAPI 17 #endif 18 #endif 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #define SERVICES_ACTIVE_DATABASEW L"ServicesActive" 25 #define SERVICES_FAILED_DATABASEW L"ServicesFailed" 26 27 #define SERVICES_ACTIVE_DATABASEA "ServicesActive" 28 #define SERVICES_FAILED_DATABASEA "ServicesFailed" 29 30 #define SC_GROUP_IDENTIFIERW L'+' 31 #define SC_GROUP_IDENTIFIERA '+' 32 33 #define SERVICES_ACTIVE_DATABASE __MINGW_NAME_AW(SERVICES_ACTIVE_DATABASE) 34 #define SERVICES_FAILED_DATABASE __MINGW_NAME_AW(SERVICES_FAILED_DATABASE) 35 36 #define SC_GROUP_IDENTIFIER __MINGW_NAME_AW(SC_GROUP_IDENTIFIER) 37 38 #define SERVICE_NO_CHANGE 0xffffffff 39 40 #define SERVICE_ACTIVE 0x00000001 41 #define SERVICE_INACTIVE 0x00000002 42 #define SERVICE_STATE_ALL (SERVICE_ACTIVE | SERVICE_INACTIVE) 43 44 #define SERVICE_CONTROL_STOP 0x00000001 45 #define SERVICE_CONTROL_PAUSE 0x00000002 46 #define SERVICE_CONTROL_CONTINUE 0x00000003 47 #define SERVICE_CONTROL_INTERROGATE 0x00000004 48 #define SERVICE_CONTROL_SHUTDOWN 0x00000005 49 #define SERVICE_CONTROL_PARAMCHANGE 0x00000006 50 #define SERVICE_CONTROL_NETBINDADD 0x00000007 51 #define SERVICE_CONTROL_NETBINDREMOVE 0x00000008 52 #define SERVICE_CONTROL_NETBINDENABLE 0x00000009 53 #define SERVICE_CONTROL_NETBINDDISABLE 0x0000000A 54 #define SERVICE_CONTROL_DEVICEEVENT 0x0000000B 55 #define SERVICE_CONTROL_HARDWAREPROFILECHANGE 0x0000000C 56 #define SERVICE_CONTROL_POWEREVENT 0x0000000D 57 #define SERVICE_CONTROL_SESSIONCHANGE 0x0000000E 58 59 #define SERVICE_STOPPED 0x00000001 60 #define SERVICE_START_PENDING 0x00000002 61 #define SERVICE_STOP_PENDING 0x00000003 62 #define SERVICE_RUNNING 0x00000004 63 #define SERVICE_CONTINUE_PENDING 0x00000005 64 #define SERVICE_PAUSE_PENDING 0x00000006 65 #define SERVICE_PAUSED 0x00000007 66 67 #define SERVICE_ACCEPT_STOP 0x00000001 68 #define SERVICE_ACCEPT_PAUSE_CONTINUE 0x00000002 69 #define SERVICE_ACCEPT_SHUTDOWN 0x00000004 70 #define SERVICE_ACCEPT_PARAMCHANGE 0x00000008 71 #define SERVICE_ACCEPT_NETBINDCHANGE 0x00000010 72 #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE 0x00000020 73 #define SERVICE_ACCEPT_POWEREVENT 0x00000040 74 #define SERVICE_ACCEPT_SESSIONCHANGE 0x00000080 75 76 #define SC_MANAGER_CONNECT 0x0001 77 #define SC_MANAGER_CREATE_SERVICE 0x0002 78 #define SC_MANAGER_ENUMERATE_SERVICE 0x0004 79 #define SC_MANAGER_LOCK 0x0008 80 #define SC_MANAGER_QUERY_LOCK_STATUS 0x0010 81 #define SC_MANAGER_MODIFY_BOOT_CONFIG 0x0020 82 83 #define SC_MANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_LOCK | SC_MANAGER_QUERY_LOCK_STATUS | SC_MANAGER_MODIFY_BOOT_CONFIG) 84 85 #define SERVICE_QUERY_CONFIG 0x0001 86 #define SERVICE_CHANGE_CONFIG 0x0002 87 #define SERVICE_QUERY_STATUS 0x0004 88 #define SERVICE_ENUMERATE_DEPENDENTS 0x0008 89 #define SERVICE_START 0x0010 90 #define SERVICE_STOP 0x0020 91 #define SERVICE_PAUSE_CONTINUE 0x0040 92 #define SERVICE_INTERROGATE 0x0080 93 #define SERVICE_USER_DEFINED_CONTROL 0x0100 94 95 #define SERVICE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL) 96 97 #define SERVICE_RUNS_IN_SYSTEM_PROCESS 0x00000001 98 99 #define SERVICE_CONFIG_DESCRIPTION 1 100 #define SERVICE_CONFIG_FAILURE_ACTIONS 2 101 102 typedef struct _SERVICE_DESCRIPTIONA { 103 LPSTR lpDescription; 104 } SERVICE_DESCRIPTIONA,*LPSERVICE_DESCRIPTIONA; 105 106 typedef struct _SERVICE_DESCRIPTIONW { 107 LPWSTR lpDescription; 108 } SERVICE_DESCRIPTIONW,*LPSERVICE_DESCRIPTIONW; 109 110 __MINGW_TYPEDEF_AW(SERVICE_DESCRIPTION) 111 __MINGW_TYPEDEF_AW(LPSERVICE_DESCRIPTION) 112 113 typedef enum _SC_ACTION_TYPE { 114 SC_ACTION_NONE = 0,SC_ACTION_RESTART = 1,SC_ACTION_REBOOT = 2,SC_ACTION_RUN_COMMAND = 3 115 } SC_ACTION_TYPE; 116 117 typedef struct _SC_ACTION { 118 SC_ACTION_TYPE Type; 119 DWORD Delay; 120 } SC_ACTION,*LPSC_ACTION; 121 122 typedef struct _SERVICE_FAILURE_ACTIONSA { 123 DWORD dwResetPeriod; 124 LPSTR lpRebootMsg; 125 LPSTR lpCommand; 126 DWORD cActions; 127 SC_ACTION *lpsaActions; 128 } SERVICE_FAILURE_ACTIONSA,*LPSERVICE_FAILURE_ACTIONSA; 129 130 typedef struct _SERVICE_FAILURE_ACTIONSW { 131 DWORD dwResetPeriod; 132 LPWSTR lpRebootMsg; 133 LPWSTR lpCommand; 134 DWORD cActions; 135 SC_ACTION *lpsaActions; 136 } SERVICE_FAILURE_ACTIONSW,*LPSERVICE_FAILURE_ACTIONSW; 137 138 __MINGW_TYPEDEF_AW(SERVICE_FAILURE_ACTIONS) 139 __MINGW_TYPEDEF_AW(LPSERVICE_FAILURE_ACTIONS) 140 141 DECLARE_HANDLE(SC_HANDLE); 142 typedef SC_HANDLE *LPSC_HANDLE; 143 144 DECLARE_HANDLE(SERVICE_STATUS_HANDLE); 145 146 typedef enum _SC_STATUS_TYPE { 147 SC_STATUS_PROCESS_INFO = 0 148 } SC_STATUS_TYPE; 149 150 typedef enum _SC_ENUM_TYPE { 151 SC_ENUM_PROCESS_INFO = 0 152 } SC_ENUM_TYPE; 153 154 typedef struct _SERVICE_STATUS { 155 DWORD dwServiceType; 156 DWORD dwCurrentState; 157 DWORD dwControlsAccepted; 158 DWORD dwWin32ExitCode; 159 DWORD dwServiceSpecificExitCode; 160 DWORD dwCheckPoint; 161 DWORD dwWaitHint; 162 } SERVICE_STATUS,*LPSERVICE_STATUS; 163 164 typedef struct _SERVICE_STATUS_PROCESS { 165 DWORD dwServiceType; 166 DWORD dwCurrentState; 167 DWORD dwControlsAccepted; 168 DWORD dwWin32ExitCode; 169 DWORD dwServiceSpecificExitCode; 170 DWORD dwCheckPoint; 171 DWORD dwWaitHint; 172 DWORD dwProcessId; 173 DWORD dwServiceFlags; 174 } SERVICE_STATUS_PROCESS,*LPSERVICE_STATUS_PROCESS; 175 176 typedef struct _ENUM_SERVICE_STATUSA { 177 LPSTR lpServiceName; 178 LPSTR lpDisplayName; 179 SERVICE_STATUS ServiceStatus; 180 } ENUM_SERVICE_STATUSA,*LPENUM_SERVICE_STATUSA; 181 182 typedef struct _ENUM_SERVICE_STATUSW { 183 LPWSTR lpServiceName; 184 LPWSTR lpDisplayName; 185 SERVICE_STATUS ServiceStatus; 186 } ENUM_SERVICE_STATUSW,*LPENUM_SERVICE_STATUSW; 187 188 __MINGW_TYPEDEF_AW(ENUM_SERVICE_STATUS) 189 __MINGW_TYPEDEF_AW(LPENUM_SERVICE_STATUS) 190 191 typedef struct _ENUM_SERVICE_STATUS_PROCESSA { 192 LPSTR lpServiceName; 193 LPSTR lpDisplayName; 194 SERVICE_STATUS_PROCESS ServiceStatusProcess; 195 } ENUM_SERVICE_STATUS_PROCESSA,*LPENUM_SERVICE_STATUS_PROCESSA; 196 197 typedef struct _ENUM_SERVICE_STATUS_PROCESSW { 198 LPWSTR lpServiceName; 199 LPWSTR lpDisplayName; 200 SERVICE_STATUS_PROCESS ServiceStatusProcess; 201 } ENUM_SERVICE_STATUS_PROCESSW,*LPENUM_SERVICE_STATUS_PROCESSW; 202 203 __MINGW_TYPEDEF_AW(ENUM_SERVICE_STATUS_PROCESS) 204 __MINGW_TYPEDEF_AW(LPENUM_SERVICE_STATUS_PROCESS) 205 206 typedef LPVOID SC_LOCK; 207 208 typedef struct _QUERY_SERVICE_LOCK_STATUSA { 209 DWORD fIsLocked; 210 LPSTR lpLockOwner; 211 DWORD dwLockDuration; 212 } QUERY_SERVICE_LOCK_STATUSA,*LPQUERY_SERVICE_LOCK_STATUSA; 213 214 typedef struct _QUERY_SERVICE_LOCK_STATUSW { 215 DWORD fIsLocked; 216 LPWSTR lpLockOwner; 217 DWORD dwLockDuration; 218 } QUERY_SERVICE_LOCK_STATUSW,*LPQUERY_SERVICE_LOCK_STATUSW; 219 220 __MINGW_TYPEDEF_AW(QUERY_SERVICE_LOCK_STATUS) 221 __MINGW_TYPEDEF_AW(LPQUERY_SERVICE_LOCK_STATUS) 222 223 typedef struct _QUERY_SERVICE_CONFIGA { 224 DWORD dwServiceType; 225 DWORD dwStartType; 226 DWORD dwErrorControl; 227 LPSTR lpBinaryPathName; 228 LPSTR lpLoadOrderGroup; 229 DWORD dwTagId; 230 LPSTR lpDependencies; 231 LPSTR lpServiceStartName; 232 LPSTR lpDisplayName; 233 } QUERY_SERVICE_CONFIGA,*LPQUERY_SERVICE_CONFIGA; 234 235 typedef struct _QUERY_SERVICE_CONFIGW { 236 DWORD dwServiceType; 237 DWORD dwStartType; 238 DWORD dwErrorControl; 239 LPWSTR lpBinaryPathName; 240 LPWSTR lpLoadOrderGroup; 241 DWORD dwTagId; 242 LPWSTR lpDependencies; 243 LPWSTR lpServiceStartName; 244 LPWSTR lpDisplayName; 245 } QUERY_SERVICE_CONFIGW,*LPQUERY_SERVICE_CONFIGW; 246 247 __MINGW_TYPEDEF_AW(QUERY_SERVICE_CONFIG) 248 __MINGW_TYPEDEF_AW(LPQUERY_SERVICE_CONFIG) 249 250 typedef VOID (WINAPI *LPSERVICE_MAIN_FUNCTIONW)(DWORD dwNumServicesArgs,LPWSTR *lpServiceArgVectors); 251 typedef VOID (WINAPI *LPSERVICE_MAIN_FUNCTIONA)(DWORD dwNumServicesArgs,LPSTR *lpServiceArgVectors); 252 253 #define LPSERVICE_MAIN_FUNCTION __MINGW_NAME_AW(LPSERVICE_MAIN_FUNCTION) 254 255 typedef struct _SERVICE_TABLE_ENTRYA { 256 LPSTR lpServiceName; 257 LPSERVICE_MAIN_FUNCTIONA lpServiceProc; 258 } SERVICE_TABLE_ENTRYA,*LPSERVICE_TABLE_ENTRYA; 259 260 typedef struct _SERVICE_TABLE_ENTRYW { 261 LPWSTR lpServiceName; 262 LPSERVICE_MAIN_FUNCTIONW lpServiceProc; 263 } SERVICE_TABLE_ENTRYW,*LPSERVICE_TABLE_ENTRYW; 264 265 __MINGW_TYPEDEF_AW(SERVICE_TABLE_ENTRY) 266 __MINGW_TYPEDEF_AW(LPSERVICE_TABLE_ENTRY) 267 268 typedef VOID (WINAPI *LPHANDLER_FUNCTION)(DWORD dwControl); 269 typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD dwControl,DWORD dwEventType,LPVOID lpEventData,LPVOID lpContext); 270 271 #define ChangeServiceConfig __MINGW_NAME_AW(ChangeServiceConfig) 272 #define ChangeServiceConfig2 __MINGW_NAME_AW(ChangeServiceConfig2) 273 #define CreateService __MINGW_NAME_AW(CreateService) 274 #define EnumDependentServices __MINGW_NAME_AW(EnumDependentServices) 275 #define EnumServicesStatus __MINGW_NAME_AW(EnumServicesStatus) 276 #define EnumServicesStatusEx __MINGW_NAME_AW(EnumServicesStatusEx) 277 #define GetServiceKeyName __MINGW_NAME_AW(GetServiceKeyName) 278 #define GetServiceDisplayName __MINGW_NAME_AW(GetServiceDisplayName) 279 #define OpenSCManager __MINGW_NAME_AW(OpenSCManager) 280 #define OpenService __MINGW_NAME_AW(OpenService) 281 #define QueryServiceConfig __MINGW_NAME_AW(QueryServiceConfig) 282 #define QueryServiceConfig2 __MINGW_NAME_AW(QueryServiceConfig2) 283 #define QueryServiceLockStatus __MINGW_NAME_AW(QueryServiceLockStatus) 284 #define RegisterServiceCtrlHandler __MINGW_NAME_AW(RegisterServiceCtrlHandler) 285 #define RegisterServiceCtrlHandlerEx __MINGW_NAME_AW(RegisterServiceCtrlHandlerEx) 286 #define StartServiceCtrlDispatcher __MINGW_NAME_AW(StartServiceCtrlDispatcher) 287 #define StartService __MINGW_NAME_AW(StartService) 288 289 WINADVAPI WINBOOL WINAPI ChangeServiceConfigA(SC_HANDLE hService,DWORD dwServiceType,DWORD dwStartType,DWORD dwErrorControl,LPCSTR lpBinaryPathName,LPCSTR lpLoadOrderGroup,LPDWORD lpdwTagId,LPCSTR lpDependencies,LPCSTR lpServiceStartName,LPCSTR lpPassword,LPCSTR lpDisplayName); 290 WINADVAPI WINBOOL WINAPI ChangeServiceConfigW(SC_HANDLE hService,DWORD dwServiceType,DWORD dwStartType,DWORD dwErrorControl,LPCWSTR lpBinaryPathName,LPCWSTR lpLoadOrderGroup,LPDWORD lpdwTagId,LPCWSTR lpDependencies,LPCWSTR lpServiceStartName,LPCWSTR lpPassword,LPCWSTR lpDisplayName); 291 WINADVAPI WINBOOL WINAPI ChangeServiceConfig2A(SC_HANDLE hService,DWORD dwInfoLevel,LPVOID lpInfo); 292 WINADVAPI WINBOOL WINAPI ChangeServiceConfig2W(SC_HANDLE hService,DWORD dwInfoLevel,LPVOID lpInfo); 293 WINADVAPI WINBOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject); 294 WINADVAPI WINBOOL WINAPI ControlService(SC_HANDLE hService,DWORD dwControl,LPSERVICE_STATUS lpServiceStatus); 295 WINADVAPI SC_HANDLE WINAPI CreateServiceA(SC_HANDLE hSCManager,LPCSTR lpServiceName,LPCSTR lpDisplayName,DWORD dwDesiredAccess,DWORD dwServiceType,DWORD dwStartType,DWORD dwErrorControl,LPCSTR lpBinaryPathName,LPCSTR lpLoadOrderGroup,LPDWORD lpdwTagId,LPCSTR lpDependencies,LPCSTR lpServiceStartName,LPCSTR lpPassword); 296 WINADVAPI SC_HANDLE WINAPI CreateServiceW(SC_HANDLE hSCManager,LPCWSTR lpServiceName,LPCWSTR lpDisplayName,DWORD dwDesiredAccess,DWORD dwServiceType,DWORD dwStartType,DWORD dwErrorControl,LPCWSTR lpBinaryPathName,LPCWSTR lpLoadOrderGroup,LPDWORD lpdwTagId,LPCWSTR lpDependencies,LPCWSTR lpServiceStartName,LPCWSTR lpPassword); 297 WINADVAPI WINBOOL WINAPI DeleteService(SC_HANDLE hService); 298 WINADVAPI WINBOOL WINAPI EnumDependentServicesA(SC_HANDLE hService,DWORD dwServiceState,LPENUM_SERVICE_STATUSA lpServices,DWORD cbBufSize,LPDWORD pcbBytesNeeded,LPDWORD lpServicesReturned); 299 WINADVAPI WINBOOL WINAPI EnumDependentServicesW(SC_HANDLE hService,DWORD dwServiceState,LPENUM_SERVICE_STATUSW lpServices,DWORD cbBufSize,LPDWORD pcbBytesNeeded,LPDWORD lpServicesReturned); 300 WINADVAPI WINBOOL WINAPI EnumServicesStatusA(SC_HANDLE hSCManager,DWORD dwServiceType,DWORD dwServiceState,LPENUM_SERVICE_STATUSA lpServices,DWORD cbBufSize,LPDWORD pcbBytesNeeded,LPDWORD lpServicesReturned,LPDWORD lpResumeHandle); 301 WINADVAPI WINBOOL WINAPI EnumServicesStatusW(SC_HANDLE hSCManager,DWORD dwServiceType,DWORD dwServiceState,LPENUM_SERVICE_STATUSW lpServices,DWORD cbBufSize,LPDWORD pcbBytesNeeded,LPDWORD lpServicesReturned,LPDWORD lpResumeHandle); 302 WINADVAPI WINBOOL WINAPI EnumServicesStatusExA(SC_HANDLE hSCManager,SC_ENUM_TYPE InfoLevel,DWORD dwServiceType,DWORD dwServiceState,LPBYTE lpServices,DWORD cbBufSize,LPDWORD pcbBytesNeeded,LPDWORD lpServicesReturned,LPDWORD lpResumeHandle,LPCSTR pszGroupName); 303 WINADVAPI WINBOOL WINAPI EnumServicesStatusExW(SC_HANDLE hSCManager,SC_ENUM_TYPE InfoLevel,DWORD dwServiceType,DWORD dwServiceState,LPBYTE lpServices,DWORD cbBufSize,LPDWORD pcbBytesNeeded,LPDWORD lpServicesReturned,LPDWORD lpResumeHandle,LPCWSTR pszGroupName); 304 WINADVAPI WINBOOL WINAPI GetServiceKeyNameA(SC_HANDLE hSCManager,LPCSTR lpDisplayName,LPSTR lpServiceName,LPDWORD lpcchBuffer); 305 WINADVAPI WINBOOL WINAPI GetServiceKeyNameW(SC_HANDLE hSCManager,LPCWSTR lpDisplayName,LPWSTR lpServiceName,LPDWORD lpcchBuffer); 306 WINADVAPI WINBOOL WINAPI GetServiceDisplayNameA(SC_HANDLE hSCManager,LPCSTR lpServiceName,LPSTR lpDisplayName,LPDWORD lpcchBuffer); 307 WINADVAPI WINBOOL WINAPI GetServiceDisplayNameW(SC_HANDLE hSCManager,LPCWSTR lpServiceName,LPWSTR lpDisplayName,LPDWORD lpcchBuffer); 308 WINADVAPI SC_LOCK WINAPI LockServiceDatabase(SC_HANDLE hSCManager); 309 WINADVAPI WINBOOL WINAPI NotifyBootConfigStatus(WINBOOL BootAcceptable); 310 WINADVAPI SC_HANDLE WINAPI OpenSCManagerA(LPCSTR lpMachineName,LPCSTR lpDatabaseName,DWORD dwDesiredAccess); 311 WINADVAPI SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName,LPCWSTR lpDatabaseName,DWORD dwDesiredAccess); 312 WINADVAPI SC_HANDLE WINAPI OpenServiceA(SC_HANDLE hSCManager,LPCSTR lpServiceName,DWORD dwDesiredAccess); 313 WINADVAPI SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager,LPCWSTR lpServiceName,DWORD dwDesiredAccess); 314 WINADVAPI WINBOOL WINAPI QueryServiceConfigA(SC_HANDLE hService,LPQUERY_SERVICE_CONFIGA lpServiceConfig,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 315 WINADVAPI WINBOOL WINAPI QueryServiceConfigW(SC_HANDLE hService,LPQUERY_SERVICE_CONFIGW lpServiceConfig,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 316 WINADVAPI WINBOOL WINAPI QueryServiceConfig2A(SC_HANDLE hService,DWORD dwInfoLevel,LPBYTE lpBuffer,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 317 WINADVAPI WINBOOL WINAPI QueryServiceConfig2W(SC_HANDLE hService,DWORD dwInfoLevel,LPBYTE lpBuffer,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 318 WINADVAPI WINBOOL WINAPI QueryServiceLockStatusA(SC_HANDLE hSCManager,LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 319 WINADVAPI WINBOOL WINAPI QueryServiceLockStatusW(SC_HANDLE hSCManager,LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 320 WINADVAPI WINBOOL WINAPI QueryServiceObjectSecurity(SC_HANDLE hService,SECURITY_INFORMATION dwSecurityInformation,PSECURITY_DESCRIPTOR lpSecurityDescriptor,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 321 WINADVAPI WINBOOL WINAPI QueryServiceStatus(SC_HANDLE hService,LPSERVICE_STATUS lpServiceStatus); 322 WINADVAPI WINBOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService,SC_STATUS_TYPE InfoLevel,LPBYTE lpBuffer,DWORD cbBufSize,LPDWORD pcbBytesNeeded); 323 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA(LPCSTR lpServiceName,LPHANDLER_FUNCTION lpHandlerProc); 324 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR lpServiceName,LPHANDLER_FUNCTION lpHandlerProc); 325 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA(LPCSTR lpServiceName,LPHANDLER_FUNCTION_EX lpHandlerProc,LPVOID lpContext); 326 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR lpServiceName,LPHANDLER_FUNCTION_EX lpHandlerProc,LPVOID lpContext); 327 WINADVAPI WINBOOL WINAPI SetServiceObjectSecurity(SC_HANDLE hService,SECURITY_INFORMATION dwSecurityInformation,PSECURITY_DESCRIPTOR lpSecurityDescriptor); 328 WINADVAPI WINBOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE hServiceStatus,LPSERVICE_STATUS lpServiceStatus); 329 WINADVAPI WINBOOL WINAPI StartServiceCtrlDispatcherA(CONST SERVICE_TABLE_ENTRYA *lpServiceStartTable); 330 WINADVAPI WINBOOL WINAPI StartServiceCtrlDispatcherW(CONST SERVICE_TABLE_ENTRYW *lpServiceStartTable); 331 WINADVAPI WINBOOL WINAPI StartServiceA(SC_HANDLE hService,DWORD dwNumServiceArgs,LPCSTR *lpServiceArgVectors); 332 WINADVAPI WINBOOL WINAPI StartServiceW(SC_HANDLE hService,DWORD dwNumServiceArgs,LPCWSTR *lpServiceArgVectors); 333 WINADVAPI WINBOOL WINAPI UnlockServiceDatabase(SC_LOCK ScLock); 334 335 #if (_WIN32_WINNT >= 0x0600) 336 337 typedef VOID( CALLBACK * PFN_SC_NOTIFY_CALLBACK ) ( 338 PVOID pParameter 339 ); 340 341 typedef struct _SERVICE_CONTROL_STATUS_REASON_PARAMSA { 342 DWORD dwReason; 343 LPSTR pszComment; 344 SERVICE_STATUS_PROCESS ServiceStatus; 345 } SERVICE_CONTROL_STATUS_REASON_PARAMSA, *PSERVICE_CONTROL_STATUS_REASON_PARAMSA; 346 347 typedef struct _SERVICE_CONTROL_STATUS_REASON_PARAMSW { 348 DWORD dwReason; 349 LPWSTR pszComment; 350 SERVICE_STATUS_PROCESS ServiceStatus; 351 } SERVICE_CONTROL_STATUS_REASON_PARAMSW, *PSERVICE_CONTROL_STATUS_REASON_PARAMSW; 352 353 __MINGW_TYPEDEF_AW(SERVICE_CONTROL_STATUS_REASON_PARAMS) 354 __MINGW_TYPEDEF_AW(PSERVICE_CONTROL_STATUS_REASON_PARAMS) 355 356 #define SERVICE_STOP_REASON_FLAG_CUSTOM 0x20000000 357 #define SERVICE_STOP_REASON_FLAG_PLANNED 0x40000000 358 #define SERVICE_STOP_REASON_FLAG_UNPLANNED 0x10000000 359 360 #define SERVICE_STOP_REASON_MAJOR_APPLICATION 0x00050000 361 #define SERVICE_STOP_REASON_MAJOR_HARDWARE 0x00020000 362 #define SERVICE_STOP_REASON_MAJOR_NONE 0x00060000 363 #define SERVICE_STOP_REASON_MAJOR_OPERATINGSYSTEM 0x00030000 364 #define SERVICE_STOP_REASON_MAJOR_OTHER 0x00010000 365 #define SERVICE_STOP_REASON_MAJOR_SOFTWARE 0x00040000 366 367 #define SERVICE_STOP_REASON_MINOR_DISK 0x00000008 368 #define SERVICE_STOP_REASON_MINOR_ENVIRONMENT 0x0000000a 369 #define SERVICE_STOP_REASON_MINOR_HARDWARE_DRIVER 0x0000000b 370 #define SERVICE_STOP_REASON_MINOR_HUNG 0x00000006 371 #define SERVICE_STOP_REASON_MINOR_INSTALLATION 0x00000003 372 #define SERVICE_STOP_REASON_MINOR_MAINTENANCE 0x00000002 373 #define SERVICE_STOP_REASON_MINOR_MMC 0x00000016 374 #define SERVICE_STOP_REASON_MINOR_NETWORK_CONNECTIVITY 0x00000011 375 #define SERVICE_STOP_REASON_MINOR_NETWORKCARD 0x00000009 376 #define SERVICE_STOP_REASON_MINOR_NONE 0x00060000 377 #define SERVICE_STOP_REASON_MINOR_OTHER 0x00000001 378 #define SERVICE_STOP_REASON_MINOR_OTHERDRIVER 0x0000000c 379 #define SERVICE_STOP_REASON_MINOR_RECONFIG 0x00000005 380 #define SERVICE_STOP_REASON_MINOR_SECURITY 0x00000010 381 #define SERVICE_STOP_REASON_MINOR_SECURITYFIX 0x0000000f 382 #define SERVICE_STOP_REASON_MINOR_SECURITYFIX_UNINSTALL 0x00000015 383 #define SERVICE_STOP_REASON_MINOR_SERVICEPACK 0x0000000d 384 #define SERVICE_STOP_REASON_MINOR_SERVICEPACK_UNINSTALL 0x00000013 385 #define SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE 0x0000000e 386 #define SERVICE_STOP_REASON_MINOR_SOFTWARE_UPDATE_UNINSTALL 0x0000000e 387 #define SERVICE_STOP_REASON_MINOR_UNSTABLE 0x00000007 388 #define SERVICE_STOP_REASON_MINOR_UPGRADE 0x00000004 389 #define SERVICE_STOP_REASON_MINOR_WMI 0x00000012 390 391 typedef struct _SERVICE_NOTIFYA { 392 DWORD dwVersion; 393 PFN_SC_NOTIFY_CALLBACK pfnNotifyCallback; 394 PVOID pContext; 395 DWORD dwNotificationStatus; 396 SERVICE_STATUS_PROCESS ServiceStatus; 397 DWORD dwNotificationTriggered; 398 LPSTR pszServiceNames; 399 } SERVICE_NOTIFYA, *PSERVICE_NOTIFYA; 400 401 typedef struct _SERVICE_NOTIFYW { 402 DWORD dwVersion; 403 PFN_SC_NOTIFY_CALLBACK pfnNotifyCallback; 404 PVOID pContext; 405 DWORD dwNotificationStatus; 406 SERVICE_STATUS_PROCESS ServiceStatus; 407 DWORD dwNotificationTriggered; 408 LPWSTR pszServiceNames; 409 } SERVICE_NOTIFYW, *PSERVICE_NOTIFYW; 410 411 __MINGW_TYPEDEF_AW(SERVICE_NOTIFY) 412 __MINGW_TYPEDEF_AW(PSERVICE_NOTIFY) 413 414 #define SERVICE_CONFIG_DELAYED_AUTO_START_INFO 3 415 #define SERVICE_CONFIG_FAILURE_ACTIONS_FLAG 4 416 #define SERVICE_CONFIG_SERVICE_SID_INFO 5 417 #define SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO 6 418 #define SERVICE_CONFIG_PRESHUTDOWN_INFO 7 419 420 typedef struct _SERVICE_DELAYED_AUTO_START_INFO { 421 WINBOOL fDelayedAutostart; 422 } SERVICE_DELAYED_AUTO_START_INFO, *LPSERVICE_DELAYED_AUTO_START_INFO; 423 424 typedef struct _SERVICE_FAILURE_ACTIONS_FLAG { 425 WINBOOL fFailureActionsOnNonCrashFailures; 426 } SERVICE_FAILURE_ACTIONS_FLAG, *LPSERVICE_FAILURE_ACTIONS_FLAG; 427 428 typedef struct _SERVICE_PRESHUTDOWN_INFO { 429 DWORD dwPreshutdownTimeout; 430 } SERVICE_PRESHUTDOWN_INFO, *LPSERVICE_PRESHUTDOWN_INFO; 431 432 typedef struct _SERVICE_REQUIRED_PRIVILEGES_INFOA { 433 LPSTR pmszRequiredPrivileges; 434 } SERVICE_REQUIRED_PRIVILEGES_INFOA, *LPSERVICE_REQUIRED_PRIVILEGES_INFOA; 435 436 typedef struct _SERVICE_REQUIRED_PRIVILEGES_INFOW { 437 LPWSTR pmszRequiredPrivileges; 438 } SERVICE_REQUIRED_PRIVILEGES_INFOW, *LPSERVICE_REQUIRED_PRIVILEGES_INFOW; 439 440 __MINGW_TYPEDEF_AW(SERVICE_REQUIRED_PRIVILEGES_INFO) 441 442 #define SERVICE_SID_TYPE_NONE 0x00000000 443 #define SERVICE_SID_TYPE_RESTRICTED 0x00000003 444 #define SERVICE_SID_TYPE_UNRESTRICTED 0x00000001 445 446 typedef struct _SERVICE_SID_INFO { 447 DWORD dwServiceSidType; 448 } SERVICE_SID_INFO, *LPSERVICE_SID_INFO; 449 450 WINADVAPI WINBOOL WINAPI ControlServiceExA( 451 SC_HANDLE hService, 452 DWORD dwControl, 453 DWORD dwInfoLevel, 454 PVOID pControlParams 455 ); 456 457 WINADVAPI WINBOOL WINAPI ControlServiceExW( 458 SC_HANDLE hService, 459 DWORD dwControl, 460 DWORD dwInfoLevel, 461 PVOID pControlParams 462 ); 463 464 #define ControlServiceEx __MINGW_NAME_AW(ControlServiceEx) 465 466 #define NotifyServiceStatusChange __MINGW_NAME_AW(NotifyServiceStatusChange) 467 468 DWORD WINAPI NotifyServiceStatusChangeA( 469 SC_HANDLE hService, 470 DWORD dwNotifyMask, 471 PSERVICE_NOTIFYA pNotifyBuffer 472 ); 473 474 DWORD WINAPI NotifyServiceStatusChangeW( 475 SC_HANDLE hService, 476 DWORD dwNotifyMask, 477 PSERVICE_NOTIFYW pNotifyBuffer 478 ); 479 480 #endif /*(_WIN32_WINNT >= 0x0600)*/ 481 482 #ifdef __cplusplus 483 } 484 #endif 485 486 #endif /* _WINSVC_ */ 487