source: Daodan/MinGW/include/winsvc.h@ 1159

Last change on this file since 1159 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 13.7 KB
RevLine 
[1046]1#ifndef _WINSVC_H
2#define _WINSVC_H
3#if __GNUC__ >= 3
4#pragma GCC system_header
5#endif
6
7#ifndef WINADVAPI
8#define WINADVAPI
9#endif
10
11#ifdef __cplusplus
12extern "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
73
74typedef 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;
83typedef 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;
94typedef enum _SC_STATUS_TYPE {
95 SC_STATUS_PROCESS_INFO = 0
96} SC_STATUS_TYPE;
97typedef enum _SC_ENUM_TYPE {
98 SC_ENUM_PROCESS_INFO = 0
99} SC_ENUM_TYPE;
100typedef struct _ENUM_SERVICE_STATUSA {
101 LPSTR lpServiceName;
102 LPSTR lpDisplayName;
103 SERVICE_STATUS ServiceStatus;
104} ENUM_SERVICE_STATUSA,*LPENUM_SERVICE_STATUSA;
105typedef struct _ENUM_SERVICE_STATUSW {
106 LPWSTR lpServiceName;
107 LPWSTR lpDisplayName;
108 SERVICE_STATUS ServiceStatus;
109} ENUM_SERVICE_STATUSW,*LPENUM_SERVICE_STATUSW;
110typedef 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;
115typedef 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;
120typedef 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;
131typedef 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;
142typedef struct _QUERY_SERVICE_LOCK_STATUSA {
143 DWORD fIsLocked;
144 LPSTR lpLockOwner;
145 DWORD dwLockDuration;
146} QUERY_SERVICE_LOCK_STATUSA,*LPQUERY_SERVICE_LOCK_STATUSA;
147typedef struct _QUERY_SERVICE_LOCK_STATUSW {
148 DWORD fIsLocked;
149 LPWSTR lpLockOwner;
150 DWORD dwLockDuration;
151} QUERY_SERVICE_LOCK_STATUSW,*LPQUERY_SERVICE_LOCK_STATUSW;
152typedef void (WINAPI *LPSERVICE_MAIN_FUNCTIONA)(DWORD,LPSTR*);
153typedef void (WINAPI *LPSERVICE_MAIN_FUNCTIONW)(DWORD,LPWSTR*);
154typedef struct _SERVICE_TABLE_ENTRYA {
155 LPSTR lpServiceName;
156 LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
157} SERVICE_TABLE_ENTRYA,*LPSERVICE_TABLE_ENTRYA;
158typedef struct _SERVICE_TABLE_ENTRYW {
159 LPWSTR lpServiceName;
160 LPSERVICE_MAIN_FUNCTIONW lpServiceProc;
161} SERVICE_TABLE_ENTRYW,*LPSERVICE_TABLE_ENTRYW;
162DECLARE_HANDLE(SC_HANDLE);
163typedef SC_HANDLE *LPSC_HANDLE;
164typedef PVOID SC_LOCK;
165typedef DWORD SERVICE_STATUS_HANDLE;
166typedef VOID(WINAPI *LPHANDLER_FUNCTION)(DWORD);
167typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD,DWORD,LPVOID,LPVOID);
168typedef struct _SERVICE_DESCRIPTIONA {
169 LPSTR lpDescription;
170} SERVICE_DESCRIPTIONA,*LPSERVICE_DESCRIPTIONA;
171typedef struct _SERVICE_DESCRIPTIONW {
172 LPWSTR lpDescription;
173} SERVICE_DESCRIPTIONW,*LPSERVICE_DESCRIPTIONW;
174typedef 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;
180typedef struct _SC_ACTION {
181 SC_ACTION_TYPE Type;
182 DWORD Delay;
183} SC_ACTION,*LPSC_ACTION;
184typedef 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;
191typedef 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;
198
199WINADVAPI BOOL WINAPI ChangeServiceConfigA(SC_HANDLE,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR,LPCSTR);
200WINADVAPI BOOL WINAPI ChangeServiceConfigW(SC_HANDLE,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
201WINADVAPI BOOL WINAPI ChangeServiceConfig2A(SC_HANDLE,DWORD,LPVOID);
202WINADVAPI BOOL WINAPI ChangeServiceConfig2W(SC_HANDLE,DWORD,LPVOID);
203WINADVAPI BOOL WINAPI CloseServiceHandle(SC_HANDLE);
204WINADVAPI BOOL WINAPI ControlService(SC_HANDLE,DWORD,LPSERVICE_STATUS);
205WINADVAPI SC_HANDLE WINAPI CreateServiceA(SC_HANDLE,LPCSTR,LPCSTR,DWORD,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,PDWORD,LPCSTR,LPCSTR,LPCSTR);
206WINADVAPI SC_HANDLE WINAPI CreateServiceW(SC_HANDLE,LPCWSTR,LPCWSTR,DWORD,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,PDWORD,LPCWSTR,LPCWSTR,LPCWSTR);
207WINADVAPI BOOL WINAPI DeleteService(SC_HANDLE);
208WINADVAPI BOOL WINAPI EnumDependentServicesA(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSA,DWORD,PDWORD,PDWORD);
209WINADVAPI BOOL WINAPI EnumDependentServicesW(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSW,DWORD,PDWORD,PDWORD);
210WINADVAPI BOOL WINAPI EnumServicesStatusA(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSA,DWORD,PDWORD,PDWORD,PDWORD);
211WINADVAPI BOOL WINAPI EnumServicesStatusW(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSW,DWORD,PDWORD,PDWORD,PDWORD);
212WINADVAPI BOOL WINAPI EnumServicesStatusExA(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD,LPDWORD,LPCSTR);
213WINADVAPI BOOL WINAPI EnumServicesStatusExW(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD,LPDWORD,LPCWSTR);
214WINADVAPI BOOL WINAPI GetServiceDisplayNameA(SC_HANDLE,LPCSTR,LPSTR,PDWORD);
215WINADVAPI BOOL WINAPI GetServiceDisplayNameW(SC_HANDLE,LPCWSTR,LPWSTR,PDWORD);
216WINADVAPI BOOL WINAPI GetServiceKeyNameA(SC_HANDLE,LPCSTR,LPSTR,PDWORD);
217WINADVAPI BOOL WINAPI GetServiceKeyNameW(SC_HANDLE,LPCWSTR,LPWSTR,PDWORD);
218WINADVAPI SC_LOCK WINAPI LockServiceDatabase(SC_HANDLE);
219WINADVAPI BOOL WINAPI NotifyBootConfigStatus(BOOL);
220WINADVAPI SC_HANDLE WINAPI OpenSCManagerA(LPCSTR,LPCSTR,DWORD);
221WINADVAPI SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR,LPCWSTR,DWORD);
222WINADVAPI SC_HANDLE WINAPI OpenServiceA(SC_HANDLE,LPCSTR,DWORD);
223WINADVAPI SC_HANDLE WINAPI OpenServiceW(SC_HANDLE,LPCWSTR,DWORD);
224WINADVAPI BOOL WINAPI QueryServiceConfigA(SC_HANDLE,LPQUERY_SERVICE_CONFIGA,DWORD,PDWORD);
225WINADVAPI BOOL WINAPI QueryServiceConfigW(SC_HANDLE,LPQUERY_SERVICE_CONFIGW,DWORD,PDWORD);
226WINADVAPI BOOL WINAPI QueryServiceConfig2A(SC_HANDLE,DWORD,LPBYTE,DWORD,LPDWORD);
227WINADVAPI BOOL WINAPI QueryServiceConfig2W(SC_HANDLE,DWORD,LPBYTE,DWORD,LPDWORD);
228WINADVAPI BOOL WINAPI QueryServiceLockStatusA(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSA,DWORD,PDWORD);
229WINADVAPI BOOL WINAPI QueryServiceLockStatusW(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSW,DWORD,PDWORD);
230WINADVAPI BOOL WINAPI QueryServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,DWORD,LPDWORD);
231WINADVAPI BOOL WINAPI QueryServiceStatus(SC_HANDLE,LPSERVICE_STATUS);
232WINADVAPI BOOL WINAPI QueryServiceStatusEx(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD);
233WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA(LPCSTR,LPHANDLER_FUNCTION);
234WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR,LPHANDLER_FUNCTION);
235WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA(LPCSTR,LPHANDLER_FUNCTION_EX,LPVOID);
236WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR,LPHANDLER_FUNCTION_EX,LPVOID);
237WINADVAPI BOOL WINAPI SetServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
238WINADVAPI BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
239WINADVAPI BOOL WINAPI StartServiceA(SC_HANDLE,DWORD,LPCSTR*);
240WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA);
241WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW);
242WINADVAPI BOOL WINAPI StartServiceW(SC_HANDLE,DWORD,LPCWSTR*);
243WINADVAPI BOOL WINAPI UnlockServiceDatabase(SC_LOCK);
244
245#ifdef UNICODE
246typedef ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUS,*LPENUM_SERVICE_STATUS;
247typedef ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESS;
248typedef LPENUM_SERVICE_STATUS_PROCESSW LPENUM_SERVICE_STATUS_PROCESS;
249typedef QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIG,*LPQUERY_SERVICE_CONFIG;
250typedef QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUS,*LPQUERY_SERVICE_LOCK_STATUS;
251typedef SERVICE_TABLE_ENTRYW SERVICE_TABLE_ENTRY,*LPSERVICE_TABLE_ENTRY;
252typedef LPSERVICE_MAIN_FUNCTIONW LPSERVICE_MAIN_FUNCTION;
253typedef SERVICE_DESCRIPTIONW SERVICE_DESCRIPTION;
254typedef LPSERVICE_DESCRIPTIONW LPSERVICE_DESCRIPTION;
255typedef SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONS;
256typedef 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
278typedef ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUS,*LPENUM_SERVICE_STATUS;
279typedef ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESS;
280typedef LPENUM_SERVICE_STATUS_PROCESSA LPENUM_SERVICE_STATUS_PROCESS;
281typedef QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIG,*LPQUERY_SERVICE_CONFIG;
282typedef QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUS,*LPQUERY_SERVICE_LOCK_STATUS;
283typedef SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRY,*LPSERVICE_TABLE_ENTRY;
284typedef LPSERVICE_MAIN_FUNCTIONA LPSERVICE_MAIN_FUNCTION;
285typedef SERVICE_DESCRIPTIONA SERVICE_DESCRIPTION;
286typedef LPSERVICE_DESCRIPTIONA LPSERVICE_DESCRIPTION;
287typedef SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONS;
288typedef 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
311}
312#endif
313#endif /* _WINSVC_H */
Note: See TracBrowser for help on using the repository browser.