user32: Fix enumeration for EnumWindowStations and EnumDesktops.
[wine/wine64.git] / include / winsvc.h
blobfb77789d747db9d5f2b3d89cf99d54a0045278a4
1 /*
2 * Copyright (C) the Wine project
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_WINSVC_H
20 #define __WINE_WINSVC_H
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* defined(__cplusplus) */
26 #ifdef _ADVAPI32_
27 #define WINADVAPI
28 #else
29 #define WINADVAPI DECLSPEC_IMPORT
30 #endif
32 /* Service database names */
33 #define SERVICES_ACTIVE_DATABASEA "ServicesActive"
34 #define SERVICES_FAILED_DATABASEA "ServicesFailed"
36 #if defined(__GNUC__)
37 # define SERVICES_ACTIVE_DATABASEW (const WCHAR []){ 'S','e','r','v','i','c','e','s','A','c','t','i','v','e',0 }
38 # define SERVICES_FAILED_DATABASEW (const WCHAR []){ 'S','e','r','v','i','c','e','s','F','a','i','l','e','d',0 }
39 #elif defined(_MSC_VER)
40 # define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
41 # define SERVICES_FAILED_DATABASEW L"ServicesFailed"
42 #endif
44 #define SERVICES_ACTIVE_DATABASE WINELIB_NAME_AW( SERVICES_ACTIVE_DATABASE )
45 #define SERVICES_FAILED_DATABASE WINELIB_NAME_AW( SERVICES_FAILED_DATABASE )
47 /* Service State requests */
48 #define SERVICE_ACTIVE 0x00000001
49 #define SERVICE_INACTIVE 0x00000002
50 #define SERVICE_STATE_ALL (SERVICE_ACTIVE | SERVICE_INACTIVE)
52 /* Controls */
53 #define SERVICE_CONTROL_STOP 0x00000001
54 #define SERVICE_CONTROL_PAUSE 0x00000002
55 #define SERVICE_CONTROL_CONTINUE 0x00000003
56 #define SERVICE_CONTROL_INTERROGATE 0x00000004
57 #define SERVICE_CONTROL_SHUTDOWN 0x00000005
58 #define SERVICE_CONTROL_PARAMCHANGE 0x00000006
59 #define SERVICE_CONTROL_NETBINDADD 0x00000007
60 #define SERVICE_CONTROL_NETBINDREMOVE 0x00000008
61 #define SERVICE_CONTROL_NETBINDENABLE 0x00000009
62 #define SERVICE_CONTROL_NETBINDDISABLE 0x0000000A
63 #define SERVICE_CONTROL_DEVICEEVENT 0x0000000B
64 #define SERVICE_CONTROL_HARDWAREPROFILECHANGE 0x0000000C
65 #define SERVICE_CONTROL_POWEREVENT 0x0000000D
66 #define SERVICE_CONTROL_SESSIONCHANGE 0x0000000E
68 /* Service State */
69 #define SERVICE_STOPPED 0x00000001
70 #define SERVICE_START_PENDING 0x00000002
71 #define SERVICE_STOP_PENDING 0x00000003
72 #define SERVICE_RUNNING 0x00000004
73 #define SERVICE_CONTINUE_PENDING 0x00000005
74 #define SERVICE_PAUSE_PENDING 0x00000006
75 #define SERVICE_PAUSED 0x00000007
77 /* Controls Accepted */
78 #define SERVICE_ACCEPT_STOP 0x00000001
79 #define SERVICE_ACCEPT_PAUSE_CONTINUE 0x00000002
80 #define SERVICE_ACCEPT_SHUTDOWN 0x00000004
81 #define SERVICE_ACCEPT_PARAMCHANGE 0x00000008
82 #define SERVICE_ACCEPT_NETBINDCHANGE 0x00000010
83 #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE 0x00000020
84 #define SERVICE_ACCEPT_POWEREVENT 0x00000040
85 #define SERVICE_ACCEPT_SESSIONCHANGE 0x00000080
87 /* Service Control Manager Object access types */
88 #define SC_MANAGER_CONNECT 0x0001
89 #define SC_MANAGER_CREATE_SERVICE 0x0002
90 #define SC_MANAGER_ENUMERATE_SERVICE 0x0004
91 #define SC_MANAGER_LOCK 0x0008
92 #define SC_MANAGER_QUERY_LOCK_STATUS 0x0010
93 #define SC_MANAGER_MODIFY_BOOT_CONFIG 0x0020
94 #define SC_MANAGER_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | \
95 SC_MANAGER_CONNECT | \
96 SC_MANAGER_CREATE_SERVICE | \
97 SC_MANAGER_ENUMERATE_SERVICE | \
98 SC_MANAGER_LOCK | \
99 SC_MANAGER_QUERY_LOCK_STATUS | \
100 SC_MANAGER_MODIFY_BOOT_CONFIG )
102 #define SERVICE_QUERY_CONFIG 0x0001
103 #define SERVICE_CHANGE_CONFIG 0x0002
104 #define SERVICE_QUERY_STATUS 0x0004
105 #define SERVICE_ENUMERATE_DEPENDENTS 0x0008
106 #define SERVICE_START 0x0010
107 #define SERVICE_STOP 0x0020
108 #define SERVICE_PAUSE_CONTINUE 0x0040
109 #define SERVICE_INTERROGATE 0x0080
110 #define SERVICE_USER_DEFINED_CONTROL 0x0100
112 #define SERVICE_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | \
113 SERVICE_QUERY_CONFIG | \
114 SERVICE_CHANGE_CONFIG | \
115 SERVICE_QUERY_STATUS | \
116 SERVICE_ENUMERATE_DEPENDENTS | \
117 SERVICE_START | \
118 SERVICE_STOP | \
119 SERVICE_PAUSE_CONTINUE | \
120 SERVICE_INTERROGATE | \
121 SERVICE_USER_DEFINED_CONTROL )
123 #define SERVICE_NO_CHANGE 0xffffffff
126 /* Handle types */
128 DECLARE_HANDLE(SC_HANDLE);
129 typedef SC_HANDLE *LPSC_HANDLE;
130 DECLARE_HANDLE(SERVICE_STATUS_HANDLE);
131 typedef LPVOID SC_LOCK;
133 /* Service status structure */
135 typedef struct _SERVICE_STATUS {
136 DWORD dwServiceType;
137 DWORD dwCurrentState;
138 DWORD dwControlsAccepted;
139 DWORD dwWin32ExitCode;
140 DWORD dwServiceSpecificExitCode;
141 DWORD dwCheckPoint;
142 DWORD dwWaitHint;
143 } SERVICE_STATUS, *LPSERVICE_STATUS;
145 /* Service status process structure */
147 typedef struct _SERVICE_STATUS_PROCESS
149 DWORD dwServiceType;
150 DWORD dwCurrentState;
151 DWORD dwControlsAccepted;
152 DWORD dwWin32ExitCode;
153 DWORD dwServiceSpecificExitCode;
154 DWORD dwCheckPoint;
155 DWORD dwWaitHint;
156 DWORD dwProcessId;
157 DWORD dwServiceFlags;
158 } SERVICE_STATUS_PROCESS, *LPSERVICE_STATUS_PROCESS;
160 typedef enum _SC_STATUS_TYPE {
161 SC_STATUS_PROCESS_INFO = 0
162 } SC_STATUS_TYPE;
164 /* Service main function prototype */
166 typedef VOID (CALLBACK *LPSERVICE_MAIN_FUNCTIONA)(DWORD,LPSTR*);
167 typedef VOID (CALLBACK *LPSERVICE_MAIN_FUNCTIONW)(DWORD,LPWSTR*);
168 DECL_WINELIB_TYPE_AW(LPSERVICE_MAIN_FUNCTION)
170 /* Service start table */
172 typedef struct _SERVICE_TABLE_ENTRYA {
173 LPSTR lpServiceName;
174 LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
175 } SERVICE_TABLE_ENTRYA, *LPSERVICE_TABLE_ENTRYA;
177 typedef struct _SERVICE_TABLE_ENTRYW {
178 LPWSTR lpServiceName;
179 LPSERVICE_MAIN_FUNCTIONW lpServiceProc;
180 } SERVICE_TABLE_ENTRYW, *LPSERVICE_TABLE_ENTRYW;
182 DECL_WINELIB_TYPE_AW(SERVICE_TABLE_ENTRY)
183 DECL_WINELIB_TYPE_AW(LPSERVICE_TABLE_ENTRY)
185 /* Service status enumeration structure */
187 typedef struct _ENUM_SERVICE_STATUSA {
188 LPSTR lpServiceName;
189 LPSTR lpDisplayName;
190 SERVICE_STATUS ServiceStatus;
191 } ENUM_SERVICE_STATUSA, *LPENUM_SERVICE_STATUSA;
193 typedef struct _ENUM_SERVICE_STATUSW {
194 LPWSTR lpServiceName;
195 LPWSTR lpDisplayName;
196 SERVICE_STATUS ServiceStatus;
197 } ENUM_SERVICE_STATUSW, *LPENUM_SERVICE_STATUSW;
199 DECL_WINELIB_TYPE_AW(ENUM_SERVICE_STATUS)
200 DECL_WINELIB_TYPE_AW(LPENUM_SERVICE_STATUS)
202 typedef struct _ENUM_SERVICE_STATUS_PROCESSA {
203 LPSTR lpServiceName;
204 LPSTR lpDisplayName;
205 SERVICE_STATUS_PROCESS ServiceStatusProcess;
206 } ENUM_SERVICE_STATUS_PROCESSA, *LPENUM_SERVICE_STATUS_PROCESSA;
208 typedef struct _ENUM_SERVICE_STATUS_PROCESSW {
209 LPWSTR lpServiceName;
210 LPWSTR lpDisplayName;
211 SERVICE_STATUS_PROCESS ServiceStatusProcess;
212 } ENUM_SERVICE_STATUS_PROCESSW, *LPENUM_SERVICE_STATUS_PROCESSW;
214 DECL_WINELIB_TYPE_AW(ENUM_SERVICE_STATUS_PROCESS)
215 DECL_WINELIB_TYPE_AW(LPENUM_SERVICE_STATUS_PROCESS)
217 typedef enum _SC_ENUM_TYPE {
218 SC_ENUM_PROCESS_INFO = 0
219 } SC_ENUM_TYPE;
221 typedef struct _QUERY_SERVICE_CONFIGA {
222 DWORD dwServiceType;
223 DWORD dwStartType;
224 DWORD dwErrorControl;
225 LPSTR lpBinaryPathName;
226 LPSTR lpLoadOrderGroup;
227 DWORD dwTagId;
228 LPSTR lpDependencies;
229 LPSTR lpServiceStartName;
230 LPSTR lpDisplayName;
231 } QUERY_SERVICE_CONFIGA, *LPQUERY_SERVICE_CONFIGA;
233 typedef struct _QUERY_SERVICE_CONFIGW {
234 DWORD dwServiceType;
235 DWORD dwStartType;
236 DWORD dwErrorControl;
237 LPWSTR lpBinaryPathName;
238 LPWSTR lpLoadOrderGroup;
239 DWORD dwTagId;
240 LPWSTR lpDependencies;
241 LPWSTR lpServiceStartName;
242 LPWSTR lpDisplayName;
243 } QUERY_SERVICE_CONFIGW, *LPQUERY_SERVICE_CONFIGW;
245 /* defines and structures for ChangeServiceConfig2 */
246 #define SERVICE_CONFIG_DESCRIPTION 1
247 #define SERVICE_CONFIG_FAILURE_ACTIONS 2
249 typedef struct _SERVICE_DESCRIPTIONA {
250 LPSTR lpDescription;
251 } SERVICE_DESCRIPTIONA,*LPSERVICE_DESCRIPTIONA;
253 typedef struct _SERVICE_DESCRIPTIONW {
254 LPWSTR lpDescription;
255 } SERVICE_DESCRIPTIONW,*LPSERVICE_DESCRIPTIONW;
257 DECL_WINELIB_TYPE_AW(SERVICE_DESCRIPTION)
258 DECL_WINELIB_TYPE_AW(LPSERVICE_DESCRIPTION)
260 typedef enum _SC_ACTION_TYPE {
261 SC_ACTION_NONE = 0,
262 SC_ACTION_RESTART = 1,
263 SC_ACTION_REBOOT = 2,
264 SC_ACTION_RUN_COMMAND = 3
265 } SC_ACTION_TYPE;
267 typedef struct _SC_ACTION {
268 SC_ACTION_TYPE Type;
269 DWORD Delay;
270 } SC_ACTION,*LPSC_ACTION;
272 typedef struct _SERVICE_FAILURE_ACTIONSA {
273 DWORD dwResetPeriod;
274 LPSTR lpRebootMsg;
275 LPSTR lpCommand;
276 DWORD cActions;
277 SC_ACTION * lpsaActions;
278 } SERVICE_FAILURE_ACTIONSA,*LPSERVICE_FAILURE_ACTIONSA;
280 typedef struct _SERVICE_FAILURE_ACTIONSW {
281 DWORD dwResetPeriod;
282 LPWSTR lpRebootMsg;
283 LPWSTR lpCommand;
284 DWORD cActions;
285 SC_ACTION * lpsaActions;
286 } SERVICE_FAILURE_ACTIONSW,*LPSERVICE_FAILURE_ACTIONSW;
288 DECL_WINELIB_TYPE_AW(SERVICE_FAILURE_ACTIONS)
289 DECL_WINELIB_TYPE_AW(LPSERVICE_FAILURE_ACTIONS)
291 typedef struct _QUERY_SERVICE_LOCK_STATUSA
293 DWORD fIsLocked;
294 LPSTR lpLockOwner;
295 DWORD dwLockDuration;
296 } QUERY_SERVICE_LOCK_STATUSA, *LPQUERY_SERVICE_LOCK_STATUSA;
298 typedef struct _QUERY_SERVICE_LOCK_STATUSW
300 DWORD fIsLocked;
301 LPWSTR lpLockOwner;
302 DWORD dwLockDuration;
303 } QUERY_SERVICE_LOCK_STATUSW, *LPQUERY_SERVICE_LOCK_STATUSW;
305 DECL_WINELIB_TYPE_AW(QUERY_SERVICE_LOCK_STATUS)
307 /* Service control handler function prototype */
309 typedef VOID (WINAPI *LPHANDLER_FUNCTION)(DWORD);
310 typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD,DWORD,LPVOID,LPVOID);
312 /* API function prototypes */
314 WINADVAPI BOOL WINAPI ChangeServiceConfigA(SC_HANDLE,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR,LPCSTR);
315 WINADVAPI BOOL WINAPI ChangeServiceConfigW(SC_HANDLE,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
316 #define ChangeServiceConfig WINELIB_NAME_AW(ChangeServiceConfig)
317 WINADVAPI BOOL WINAPI ChangeServiceConfig2A(SC_HANDLE,DWORD,LPVOID);
318 WINADVAPI BOOL WINAPI ChangeServiceConfig2W(SC_HANDLE,DWORD,LPVOID);
319 #define ChangeServiceConfig2 WINELIB_NAME_AW(ChangeServiceConfig2)
320 WINADVAPI BOOL WINAPI CloseServiceHandle(SC_HANDLE);
321 WINADVAPI BOOL WINAPI ControlService(SC_HANDLE,DWORD,LPSERVICE_STATUS);
322 WINADVAPI SC_HANDLE WINAPI CreateServiceA(SC_HANDLE,LPCSTR,LPCSTR,DWORD,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR);
323 WINADVAPI SC_HANDLE WINAPI CreateServiceW(SC_HANDLE,LPCWSTR,LPCWSTR,DWORD,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR);
324 #define CreateService WINELIB_NAME_AW(CreateService)
325 WINADVAPI BOOL WINAPI DeleteService(SC_HANDLE);
326 WINADVAPI BOOL WINAPI EnumDependentServicesA(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSA,DWORD,LPDWORD,LPDWORD);
327 WINADVAPI BOOL WINAPI EnumDependentServicesW(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSW,DWORD,LPDWORD,LPDWORD);
328 #define EnumDependentServices WINELIB_NAME_AW(EnumDependentServices)
329 WINADVAPI BOOL WINAPI EnumServicesStatusA(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSA,DWORD,LPDWORD,LPDWORD,LPDWORD);
330 WINADVAPI BOOL WINAPI EnumServicesStatusW(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSW,DWORD,LPDWORD,LPDWORD,LPDWORD);
331 #define EnumServicesStatus WINELIB_NAME_AW(EnumServicesStatus)
332 WINADVAPI BOOL WINAPI EnumServicesStatusExA(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD,LPDWORD,LPCSTR);
333 WINADVAPI BOOL WINAPI EnumServicesStatusExW(SC_HANDLE,SC_ENUM_TYPE,DWORD,DWORD,LPBYTE,DWORD,LPDWORD,LPDWORD,LPDWORD,LPCWSTR);
334 #define EnumServicesStatus WINELIB_NAME_AW(EnumServicesStatus)
335 WINADVAPI BOOL WINAPI GetServiceDisplayNameA(SC_HANDLE,LPCSTR,LPSTR,LPDWORD);
336 WINADVAPI BOOL WINAPI GetServiceDisplayNameW(SC_HANDLE,LPCWSTR,LPWSTR,LPDWORD);
337 #define GetServiceDisplayName WINELIB_NAME_AW(GetServiceDisplayName)
338 WINADVAPI BOOL WINAPI GetServiceKeyNameA(SC_HANDLE,LPCSTR,LPSTR,LPDWORD);
339 WINADVAPI BOOL WINAPI GetServiceKeyNameW(SC_HANDLE,LPCWSTR,LPWSTR,LPDWORD);
340 #define GetServiceKeyName WINELIB_NAME_AW(GetServiceKeyName)
341 WINADVAPI SC_LOCK WINAPI LockServiceDatabase(SC_HANDLE);
342 WINADVAPI BOOL WINAPI NotifyBootConfigStatus(BOOL);
343 WINADVAPI SC_HANDLE WINAPI OpenSCManagerA(LPCSTR,LPCSTR,DWORD);
344 WINADVAPI SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR,LPCWSTR,DWORD);
345 #define OpenSCManager WINELIB_NAME_AW(OpenSCManager)
346 WINADVAPI SC_HANDLE WINAPI OpenServiceA(SC_HANDLE,LPCSTR,DWORD);
347 WINADVAPI SC_HANDLE WINAPI OpenServiceW(SC_HANDLE,LPCWSTR,DWORD);
348 #define OpenService WINELIB_NAME_AW(OpenService)
349 WINADVAPI BOOL WINAPI QueryServiceStatus(SC_HANDLE,LPSERVICE_STATUS);
350 WINADVAPI BOOL WINAPI QueryServiceStatusEx(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD);
351 WINADVAPI BOOL WINAPI QueryServiceConfigA(SC_HANDLE,LPQUERY_SERVICE_CONFIGA,DWORD,LPDWORD);
352 WINADVAPI BOOL WINAPI QueryServiceConfigW(SC_HANDLE,LPQUERY_SERVICE_CONFIGW,DWORD,LPDWORD);
353 #define QueryServiceConfig WINELIB_NAME_AW(QueryServiceConfig)
354 WINADVAPI BOOL WINAPI QueryServiceLockStatusA(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSA,DWORD,LPDWORD);
355 WINADVAPI BOOL WINAPI QueryServiceLockStatusW(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSW,DWORD,LPDWORD);
356 #define QueryServiceLockStatus WINELIB_NAME_AW(QueryServiceLockStatus)
357 WINADVAPI BOOL WINAPI QueryServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,DWORD,LPDWORD);
358 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA(LPCSTR,LPHANDLER_FUNCTION);
359 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR,LPHANDLER_FUNCTION);
360 #define RegisterServiceCtrlHandler WINELIB_NAME_AW(RegisterServiceCtrlHandler)
361 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA(LPCSTR,LPHANDLER_FUNCTION_EX,LPVOID);
362 WINADVAPI SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR,LPHANDLER_FUNCTION_EX,LPVOID);
363 #define RegisterServiceCtrlHandlerEx WINELIB_NAME_AW(RegisterServiceCtrlHandlerEx)
364 WINADVAPI BOOL WINAPI SetServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
365 WINADVAPI BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
366 WINADVAPI BOOL WINAPI StartServiceA(SC_HANDLE,DWORD,LPCSTR*);
367 WINADVAPI BOOL WINAPI StartServiceW(SC_HANDLE,DWORD,LPCWSTR*);
368 #define StartService WINELIB_NAME_AW(StartService)
369 WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherA(const SERVICE_TABLE_ENTRYA*);
370 WINADVAPI BOOL WINAPI StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW*);
371 #define StartServiceCtrlDispatcher WINELIB_NAME_AW(StartServiceCtrlDispatcher)
372 WINADVAPI BOOL WINAPI UnlockServiceDatabase(SC_LOCK);
374 #ifdef __cplusplus
375 } /* extern "C" */
376 #endif /* defined(__cplusplus) */
378 #endif /* !defined(__WINE_WINSVC_H) */