Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / include / winsvc.h
bloba51440f876d0fbb9c83b01f148932292afb91030
1 #ifndef _WINSVC_H
2 #define _WINSVC_H
3 #if __GNUC__ >= 3
4 #pragma GCC system_header
5 #endif
7 #ifndef WINADVAPI
8 #define WINADVAPI
9 #endif
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 #define SERVICES_ACTIVE_DATABASEA "ServicesActive"
15 #define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
16 #define SERVICES_FAILED_DATABASEA "ServicesFailed"
17 #define SERVICES_FAILED_DATABASEW L"ServicesFailed"
18 #define SC_GROUP_IDENTIFIERA '+'
19 #define SC_GROUP_IDENTIFIERW L'+'
20 #define SC_MANAGER_ALL_ACCESS 0xf003f
21 #define SC_MANAGER_CONNECT 1
22 #define SC_MANAGER_CREATE_SERVICE 2
23 #define SC_MANAGER_ENUMERATE_SERVICE 4
24 #define SC_MANAGER_LOCK 8
25 #define SC_MANAGER_QUERY_LOCK_STATUS 16
26 #define SC_MANAGER_MODIFY_BOOT_CONFIG 32
27 #define SERVICE_NO_CHANGE 0xffffffff
28 #define SERVICE_STOPPED 1
29 #define SERVICE_START_PENDING 2
30 #define SERVICE_STOP_PENDING 3
31 #define SERVICE_RUNNING 4
32 #define SERVICE_CONTINUE_PENDING 5
33 #define SERVICE_PAUSE_PENDING 6
34 #define SERVICE_PAUSED 7
35 #define SERVICE_ACCEPT_STOP 1
36 #define SERVICE_ACCEPT_PAUSE_CONTINUE 2
37 #define SERVICE_ACCEPT_SHUTDOWN 4
38 #define SERVICE_ACCEPT_PARAMCHANGE 8
39 #define SERVICE_ACCEPT_NETBINDCHANGE 16
40 #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE 32
41 #define SERVICE_ACCEPT_POWEREVENT 64
42 #define SERVICE_ACCEPT_SESSIONCHANGE 128
43 #define SERVICE_CONTROL_STOP 1
44 #define SERVICE_CONTROL_PAUSE 2
45 #define SERVICE_CONTROL_CONTINUE 3
46 #define SERVICE_CONTROL_INTERROGATE 4
47 #define SERVICE_CONTROL_SHUTDOWN 5
48 #define SERVICE_CONTROL_PARAMCHANGE 6
49 #define SERVICE_CONTROL_NETBINDADD 7
50 #define SERVICE_CONTROL_NETBINDREMOVE 8
51 #define SERVICE_CONTROL_NETBINDENABLE 9
52 #define SERVICE_CONTROL_NETBINDDISABLE 10
53 #define SERVICE_CONTROL_DEVICEEVENT 11
54 #define SERVICE_CONTROL_HARDWAREPROFILECHANGE 12
55 #define SERVICE_CONTROL_POWEREVENT 13
56 #define SERVICE_CONTROL_SESSIONCHANGE 14
57 #define SERVICE_ACTIVE 1
58 #define SERVICE_INACTIVE 2
59 #define SERVICE_STATE_ALL 3
60 #define SERVICE_QUERY_CONFIG 1
61 #define SERVICE_CHANGE_CONFIG 2
62 #define SERVICE_QUERY_STATUS 4
63 #define SERVICE_ENUMERATE_DEPENDENTS 8
64 #define SERVICE_START 16
65 #define SERVICE_STOP 32
66 #define SERVICE_PAUSE_CONTINUE 64
67 #define SERVICE_INTERROGATE 128
68 #define SERVICE_USER_DEFINED_CONTROL 256
69 #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)
70 #define SERVICE_RUNS_IN_SYSTEM_PROCESS 1
71 #define SERVICE_CONFIG_DESCRIPTION 1
72 #define SERVICE_CONFIG_FAILURE_ACTIONS 2
74 typedef struct _SERVICE_STATUS {
75 DWORD dwServiceType;
76 DWORD dwCurrentState;
77 DWORD dwControlsAccepted;
78 DWORD dwWin32ExitCode;
79 DWORD dwServiceSpecificExitCode;
80 DWORD dwCheckPoint;
81 DWORD dwWaitHint;
82 } SERVICE_STATUS,*LPSERVICE_STATUS;
83 typedef struct _SERVICE_STATUS_PROCESS {
84 DWORD dwServiceType;
85 DWORD dwCurrentState;
86 DWORD dwControlsAccepted;
87 DWORD dwWin32ExitCode;
88 DWORD dwServiceSpecificExitCode;
89 DWORD dwCheckPoint;
90 DWORD dwWaitHint;
91 DWORD dwProcessId;
92 DWORD dwServiceFlags;
93 } SERVICE_STATUS_PROCESS, *LPSERVICE_STATUS_PROCESS;
94 typedef enum _SC_STATUS_TYPE {
95 SC_STATUS_PROCESS_INFO = 0
96 } SC_STATUS_TYPE;
97 typedef enum _SC_ENUM_TYPE {
98 SC_ENUM_PROCESS_INFO = 0
99 } SC_ENUM_TYPE;
100 typedef struct _ENUM_SERVICE_STATUSA {
101 LPSTR lpServiceName;
102 LPSTR lpDisplayName;
103 SERVICE_STATUS ServiceStatus;
104 } ENUM_SERVICE_STATUSA,*LPENUM_SERVICE_STATUSA;
105 typedef struct _ENUM_SERVICE_STATUSW {
106 LPWSTR lpServiceName;
107 LPWSTR lpDisplayName;
108 SERVICE_STATUS ServiceStatus;
109 } ENUM_SERVICE_STATUSW,*LPENUM_SERVICE_STATUSW;
110 typedef struct _ENUM_SERVICE_STATUS_PROCESSA {
111 LPSTR lpServiceName;
112 LPSTR lpDisplayName;
113 SERVICE_STATUS_PROCESS ServiceStatusProcess;
114 } ENUM_SERVICE_STATUS_PROCESSA,*LPENUM_SERVICE_STATUS_PROCESSA;
115 typedef struct _ENUM_SERVICE_STATUS_PROCESSW {
116 LPWSTR lpServiceName;
117 LPWSTR lpDisplayName;
118 SERVICE_STATUS_PROCESS ServiceStatusProcess;
119 } ENUM_SERVICE_STATUS_PROCESSW,*LPENUM_SERVICE_STATUS_PROCESSW;
120 typedef struct _QUERY_SERVICE_CONFIGA {
121 DWORD dwServiceType;
122 DWORD dwStartType;
123 DWORD dwErrorControl;
124 LPSTR lpBinaryPathName;
125 LPSTR lpLoadOrderGroup;
126 DWORD dwTagId;
127 LPSTR lpDependencies;
128 LPSTR lpServiceStartName;
129 LPSTR lpDisplayName;
130 } QUERY_SERVICE_CONFIGA,*LPQUERY_SERVICE_CONFIGA;
131 typedef struct _QUERY_SERVICE_CONFIGW {
132 DWORD dwServiceType;
133 DWORD dwStartType;
134 DWORD dwErrorControl;
135 LPWSTR lpBinaryPathName;
136 LPWSTR lpLoadOrderGroup;
137 DWORD dwTagId;
138 LPWSTR lpDependencies;
139 LPWSTR lpServiceStartName;
140 LPWSTR lpDisplayName;
141 } QUERY_SERVICE_CONFIGW,*LPQUERY_SERVICE_CONFIGW;
142 typedef struct _QUERY_SERVICE_LOCK_STATUSA {
143 DWORD fIsLocked;
144 LPSTR lpLockOwner;
145 DWORD dwLockDuration;
146 } QUERY_SERVICE_LOCK_STATUSA,*LPQUERY_SERVICE_LOCK_STATUSA;
147 typedef struct _QUERY_SERVICE_LOCK_STATUSW {
148 DWORD fIsLocked;
149 LPWSTR lpLockOwner;
150 DWORD dwLockDuration;
151 } QUERY_SERVICE_LOCK_STATUSW,*LPQUERY_SERVICE_LOCK_STATUSW;
152 typedef void (WINAPI *LPSERVICE_MAIN_FUNCTIONA)(DWORD,LPSTR*);
153 typedef void (WINAPI *LPSERVICE_MAIN_FUNCTIONW)(DWORD,LPWSTR*);
154 typedef struct _SERVICE_TABLE_ENTRYA {
155 LPSTR lpServiceName;
156 LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
157 } SERVICE_TABLE_ENTRYA,*LPSERVICE_TABLE_ENTRYA;
158 typedef struct _SERVICE_TABLE_ENTRYW {
159 LPWSTR lpServiceName;
160 LPSERVICE_MAIN_FUNCTIONW lpServiceProc;
161 } SERVICE_TABLE_ENTRYW,*LPSERVICE_TABLE_ENTRYW;
162 DECLARE_HANDLE(SC_HANDLE);
163 typedef SC_HANDLE *LPSC_HANDLE;
164 typedef PVOID SC_LOCK;
165 typedef DWORD SERVICE_STATUS_HANDLE;
166 typedef VOID(WINAPI *LPHANDLER_FUNCTION)(DWORD);
167 typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD,DWORD,LPVOID,LPVOID);
168 typedef struct _SERVICE_DESCRIPTIONA {
169 LPSTR lpDescription;
170 } SERVICE_DESCRIPTIONA,*LPSERVICE_DESCRIPTIONA;
171 typedef struct _SERVICE_DESCRIPTIONW {
172 LPWSTR lpDescription;
173 } SERVICE_DESCRIPTIONW,*LPSERVICE_DESCRIPTIONW;
174 typedef enum _SC_ACTION_TYPE {
175 SC_ACTION_NONE = 0,
176 SC_ACTION_RESTART = 1,
177 SC_ACTION_REBOOT = 2,
178 SC_ACTION_RUN_COMMAND = 3
179 } SC_ACTION_TYPE;
180 typedef struct _SC_ACTION {
181 SC_ACTION_TYPE Type;
182 DWORD Delay;
183 } SC_ACTION,*LPSC_ACTION;
184 typedef struct _SERVICE_FAILURE_ACTIONSA {
185 DWORD dwResetPeriod;
186 LPSTR lpRebootMsg;
187 LPSTR lpCommand;
188 DWORD cActions;
189 SC_ACTION * lpsaActions;
190 } SERVICE_FAILURE_ACTIONSA,*LPSERVICE_FAILURE_ACTIONSA;
191 typedef struct _SERVICE_FAILURE_ACTIONSW {
192 DWORD dwResetPeriod;
193 LPWSTR lpRebootMsg;
194 LPWSTR lpCommand;
195 DWORD cActions;
196 SC_ACTION * lpsaActions;
197 } SERVICE_FAILURE_ACTIONSW,*LPSERVICE_FAILURE_ACTIONSW;
199 WINADVAPI BOOL WINAPI ChangeServiceConfigA(SC_HANDLE,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR,LPCSTR);
200 WINADVAPI BOOL WINAPI ChangeServiceConfigW(SC_HANDLE,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
201 WINADVAPI BOOL WINAPI ChangeServiceConfig2A(SC_HANDLE,DWORD,LPVOID);
202 WINADVAPI BOOL WINAPI ChangeServiceConfig2W(SC_HANDLE,DWORD,LPVOID);
203 WINADVAPI BOOL WINAPI CloseServiceHandle(SC_HANDLE);
204 WINADVAPI BOOL WINAPI ControlService(SC_HANDLE,DWORD,LPSERVICE_STATUS);
205 WINADVAPI SC_HANDLE WINAPI CreateServiceA(SC_HANDLE,LPCSTR,LPCSTR,DWORD,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,PDWORD,LPCSTR,LPCSTR,LPCSTR);
206 WINADVAPI SC_HANDLE WINAPI CreateServiceW(SC_HANDLE,LPCWSTR,LPCWSTR,DWORD,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,PDWORD,LPCWSTR,LPCWSTR,LPCWSTR);
207 WINADVAPI BOOL WINAPI DeleteService(SC_HANDLE);
208 WINADVAPI BOOL WINAPI EnumDependentServicesA(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSA,DWORD,PDWORD,PDWORD);
209 WINADVAPI BOOL WINAPI EnumDependentServicesW(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSW,DWORD,PDWORD,PDWORD);
210 WINADVAPI BOOL WINAPI EnumServicesStatusA(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSA,DWORD,PDWORD,PDWORD,PDWORD);
211 WINADVAPI BOOL WINAPI EnumServicesStatusW(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSW,DWORD,PDWORD,PDWORD,PDWORD);
212 WINADVAPI BOOL WINAPI EnumServicesStatusExA(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD,LPDWORD,LPCSTR);
213 WINADVAPI BOOL WINAPI EnumServicesStatusExW(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD,LPDWORD,LPCWSTR);
214 WINADVAPI BOOL WINAPI GetServiceDisplayNameA(SC_HANDLE,LPCSTR,LPSTR,PDWORD);
215 WINADVAPI BOOL WINAPI GetServiceDisplayNameW(SC_HANDLE,LPCWSTR,LPWSTR,PDWORD);
216 WINADVAPI BOOL WINAPI GetServiceKeyNameA(SC_HANDLE,LPCSTR,LPSTR,PDWORD);
217 WINADVAPI BOOL WINAPI GetServiceKeyNameW(SC_HANDLE,LPCWSTR,LPWSTR,PDWORD);
218 WINADVAPI SC_LOCK WINAPI LockServiceDatabase(SC_HANDLE);
219 WINADVAPI BOOL WINAPI NotifyBootConfigStatus(BOOL);
220 WINADVAPI SC_HANDLE WINAPI OpenSCManagerA(LPCSTR,LPCSTR,DWORD);
221 WINADVAPI SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR,LPCWSTR,DWORD);
222 WINADVAPI SC_HANDLE WINAPI OpenServiceA(SC_HANDLE,LPCSTR,DWORD);
223 WINADVAPI SC_HANDLE WINAPI OpenServiceW(SC_HANDLE,LPCWSTR,DWORD);
224 WINADVAPI BOOL WINAPI QueryServiceConfigA(SC_HANDLE,LPQUERY_SERVICE_CONFIGA,DWORD,PDWORD);
225 WINADVAPI BOOL WINAPI QueryServiceConfigW(SC_HANDLE,LPQUERY_SERVICE_CONFIGW,DWORD,PDWORD);
226 WINADVAPI BOOL WINAPI QueryServiceConfig2A(SC_HANDLE,DWORD,LPBYTE,DWORD,LPDWORD);
227 WINADVAPI BOOL WINAPI QueryServiceConfig2W(SC_HANDLE,DWORD,LPBYTE,DWORD,LPDWORD);
228 WINADVAPI BOOL WINAPI QueryServiceLockStatusA(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSA,DWORD,PDWORD);
229 WINADVAPI BOOL WINAPI QueryServiceLockStatusW(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSW,DWORD,PDWORD);
230 WINADVAPI BOOL WINAPI QueryServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,DWORD,LPDWORD);
231 WINADVAPI BOOL WINAPI QueryServiceStatus(SC_HANDLE,LPSERVICE_STATUS);
232 WINADVAPI BOOL WINAPI QueryServiceStatusEx(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD);
233 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA(LPCSTR,LPHANDLER_FUNCTION);
234 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR,LPHANDLER_FUNCTION);
235 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA(LPCSTR,LPHANDLER_FUNCTION_EX,LPVOID);
236 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR,LPHANDLER_FUNCTION_EX,LPVOID);
237 WINADVAPI BOOL WINAPI SetServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
238 WINADVAPI BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
239 WINADVAPI BOOL WINAPI StartServiceA(SC_HANDLE,DWORD,LPCSTR*);
240 WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA);
241 WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW);
242 WINADVAPI BOOL WINAPI StartServiceW(SC_HANDLE,DWORD,LPCWSTR*);
243 WINADVAPI BOOL WINAPI UnlockServiceDatabase(SC_LOCK);
245 #ifdef UNICODE
246 typedef ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUS,*LPENUM_SERVICE_STATUS;
247 typedef ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESS;
248 typedef LPENUM_SERVICE_STATUS_PROCESSW LPENUM_SERVICE_STATUS_PROCESS;
249 typedef QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIG,*LPQUERY_SERVICE_CONFIG;
250 typedef QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUS,*LPQUERY_SERVICE_LOCK_STATUS;
251 typedef SERVICE_TABLE_ENTRYW SERVICE_TABLE_ENTRY,*LPSERVICE_TABLE_ENTRY;
252 typedef LPSERVICE_MAIN_FUNCTIONW LPSERVICE_MAIN_FUNCTION;
253 typedef SERVICE_DESCRIPTIONW SERVICE_DESCRIPTION;
254 typedef LPSERVICE_DESCRIPTIONW LPSERVICE_DESCRIPTION;
255 typedef SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONS;
256 typedef LPSERVICE_FAILURE_ACTIONSW LPSERVICE_FAILURE_ACTIONS;
257 #define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEW
258 #define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEW
259 #define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERW
260 #define ChangeServiceConfig ChangeServiceConfigW
261 #define ChangeServiceConfig2 ChangeServiceConfig2W
262 #define CreateService CreateServiceW
263 #define EnumDependentServices EnumDependentServicesW
264 #define EnumServicesStatus EnumServicesStatusW
265 #define EnumServicesStatusEx EnumServicesStatusExW
266 #define GetServiceDisplayName GetServiceDisplayNameW
267 #define GetServiceKeyName GetServiceKeyNameW
268 #define OpenSCManager OpenSCManagerW
269 #define OpenService OpenServiceW
270 #define QueryServiceConfig QueryServiceConfigW
271 #define QueryServiceConfig2 QueryServiceConfig2W
272 #define QueryServiceLockStatus QueryServiceLockStatusW
273 #define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerW
274 #define RegisterServiceCtrlHandlerEx RegisterServiceCtrlHandlerExW
275 #define StartService StartServiceW
276 #define StartServiceCtrlDispatcher StartServiceCtrlDispatcherW
277 #else
278 typedef ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUS,*LPENUM_SERVICE_STATUS;
279 typedef ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESS;
280 typedef LPENUM_SERVICE_STATUS_PROCESSA LPENUM_SERVICE_STATUS_PROCESS;
281 typedef QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIG,*LPQUERY_SERVICE_CONFIG;
282 typedef QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUS,*LPQUERY_SERVICE_LOCK_STATUS;
283 typedef SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRY,*LPSERVICE_TABLE_ENTRY;
284 typedef LPSERVICE_MAIN_FUNCTIONA LPSERVICE_MAIN_FUNCTION;
285 typedef SERVICE_DESCRIPTIONA SERVICE_DESCRIPTION;
286 typedef LPSERVICE_DESCRIPTIONA LPSERVICE_DESCRIPTION;
287 typedef SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONS;
288 typedef LPSERVICE_FAILURE_ACTIONSA LPSERVICE_FAILURE_ACTIONS;
289 #define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEA
290 #define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEA
291 #define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERA
292 #define ChangeServiceConfig ChangeServiceConfigA
293 #define ChangeServiceConfig2 ChangeServiceConfig2A
294 #define CreateService CreateServiceA
295 #define EnumDependentServices EnumDependentServicesA
296 #define EnumServicesStatus EnumServicesStatusA
297 #define EnumServicesStatusEx EnumServicesStatusExA
298 #define GetServiceDisplayName GetServiceDisplayNameA
299 #define GetServiceKeyName GetServiceKeyNameA
300 #define OpenSCManager OpenSCManagerA
301 #define OpenService OpenServiceA
302 #define QueryServiceConfig QueryServiceConfigA
303 #define QueryServiceConfig2 QueryServiceConfig2A
304 #define QueryServiceLockStatus QueryServiceLockStatusA
305 #define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerA
306 #define RegisterServiceCtrlHandlerEx RegisterServiceCtrlHandlerExA
307 #define StartService StartServiceA
308 #define StartServiceCtrlDispatcher StartServiceCtrlDispatcherA
309 #endif
310 #ifdef __cplusplus
312 #endif
313 #endif /* _WINSVC_H */