Don't change the UI level during ExecuteAction.
[wine.git] / include / winsvc.h
blob6cf23df05f1ff663babf1a4ac5347ab0a40fdd6f
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef __WINE_WINSVC_H
20 #define __WINE_WINSVC_H
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* defined(__cplusplus) */
26 /* Service database names */
27 #define SERVICES_ACTIVE_DATABASEA "ServicesActive"
28 #define SERVICES_FAILED_DATABASEA "ServicesFailed"
30 #if defined(__GNUC__)
31 # define SERVICES_ACTIVE_DATABASEW (const WCHAR []){ 'S','e','r','v','i','c','e','s','A','c','t','i','v','e',0 }
32 # define SERVICES_FAILED_DATABASEW (const WCHAR []){ 'S','e','r','v','i','c','e','s','F','a','i','l','e','d',0 }
33 #elif defined(_MSC_VER)
34 # define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
35 # define SERVICES_FAILED_DATABASEW L"ServicesFailed"
36 #endif
38 #define SERVICES_ACTIVE_DATABASE WINELIB_NAME_AW( SERVICES_ACTIVE_DATABASE )
39 #define SERVICES_FAILED_DATABASE WINELIB_NAME_AW( SERVICES_FAILED_DATABASE )
41 /* Controls */
42 #define SERVICE_CONTROL_STOP 0x00000001
43 #define SERVICE_CONTROL_PAUSE 0x00000002
44 #define SERVICE_CONTROL_CONTINUE 0x00000003
45 #define SERVICE_CONTROL_INTERROGATE 0x00000004
46 #define SERVICE_CONTROL_SHUTDOWN 0x00000005
47 #define SERVICE_CONTROL_PARAMCHANGE 0x00000006
48 #define SERVICE_CONTROL_NETBINDADD 0x00000007
49 #define SERVICE_CONTROL_NETBINDREMOVE 0x00000008
50 #define SERVICE_CONTROL_NETBINDENABLE 0x00000009
51 #define SERVICE_CONTROL_NETBINDDISABLE 0x0000000A
52 #define SERVICE_CONTROL_DEVICEEVENT 0x0000000B
53 #define SERVICE_CONTROL_HARDWAREPROFILECHANGE 0x0000000C
54 #define SERVICE_CONTROL_POWEREVENT 0x0000000D
55 #define SERVICE_CONTROL_SESSIONCHANGE 0x0000000E
57 /* Service State */
58 #define SERVICE_STOPPED 0x00000001
59 #define SERVICE_START_PENDING 0x00000002
60 #define SERVICE_STOP_PENDING 0x00000003
61 #define SERVICE_RUNNING 0x00000004
62 #define SERVICE_CONTINUE_PENDING 0x00000005
63 #define SERVICE_PAUSE_PENDING 0x00000006
64 #define SERVICE_PAUSED 0x00000007
66 /* Controls Accepted */
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
76 /* Service Control Manager Object access types */
77 #define SC_MANAGER_CONNECT 0x0001
78 #define SC_MANAGER_CREATE_SERVICE 0x0002
79 #define SC_MANAGER_ENUMERATE_SERVICE 0x0004
80 #define SC_MANAGER_LOCK 0x0008
81 #define SC_MANAGER_QUERY_LOCK_STATUS 0x0010
82 #define SC_MANAGER_MODIFY_BOOT_CONFIG 0x0020
83 #define SC_MANAGER_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | \
84 SC_MANAGER_CONNECT | \
85 SC_MANAGER_CREATE_SERVICE | \
86 SC_MANAGER_ENUMERATE_SERVICE | \
87 SC_MANAGER_LOCK | \
88 SC_MANAGER_QUERY_LOCK_STATUS | \
89 SC_MANAGER_MODIFY_BOOT_CONFIG )
91 #define SERVICE_QUERY_CONFIG 0x0001
92 #define SERVICE_CHANGE_CONFIG 0x0002
93 #define SERVICE_QUERY_STATUS 0x0004
94 #define SERVICE_ENUMERATE_DEPENDENTS 0x0008
95 #define SERVICE_START 0x0010
96 #define SERVICE_STOP 0x0020
97 #define SERVICE_PAUSE_CONTINUE 0x0040
98 #define SERVICE_INTERROGATE 0x0080
99 #define SERVICE_USER_DEFINED_CONTROL 0x0100
101 #define SERVICE_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | \
102 SERVICE_QUERY_CONFIG | \
103 SERVICE_CHANGE_CONFIG | \
104 SERVICE_QUERY_STATUS | \
105 SERVICE_ENUMERATE_DEPENDENTS | \
106 SERVICE_START | \
107 SERVICE_STOP | \
108 SERVICE_PAUSE_CONTINUE | \
109 SERVICE_INTERROGATE | \
110 SERVICE_USER_DEFINED_CONTROL )
112 #define SERVICE_NO_CHANGE 0xffffffff
115 /* Handle types */
117 DECLARE_HANDLE(SC_HANDLE);
118 typedef SC_HANDLE *LPSC_HANDLE;
119 DECLARE_HANDLE(SERVICE_STATUS_HANDLE);
120 typedef LPVOID SC_LOCK;
122 /* Service status structure */
124 typedef struct _SERVICE_STATUS {
125 DWORD dwServiceType;
126 DWORD dwCurrentState;
127 DWORD dwControlsAccepted;
128 DWORD dwWin32ExitCode;
129 DWORD dwServiceSpecificExitCode;
130 DWORD dwCheckPoint;
131 DWORD dwWaitHint;
132 } SERVICE_STATUS, *LPSERVICE_STATUS;
134 typedef enum _SC_STATUS_TYPE {
135 SC_STATUS_PROCESS_INFO = 0
136 } SC_STATUS_TYPE;
138 /* Service main function prototype */
140 typedef VOID (CALLBACK *LPSERVICE_MAIN_FUNCTIONA)(DWORD,LPSTR*);
141 typedef VOID (CALLBACK *LPSERVICE_MAIN_FUNCTIONW)(DWORD,LPWSTR*);
142 DECL_WINELIB_TYPE_AW(LPSERVICE_MAIN_FUNCTION)
144 /* Service start table */
146 typedef struct _SERVICE_TABLE_ENTRYA {
147 LPSTR lpServiceName;
148 LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
149 } SERVICE_TABLE_ENTRYA, *LPSERVICE_TABLE_ENTRYA;
151 typedef struct _SERVICE_TABLE_ENTRYW {
152 LPWSTR lpServiceName;
153 LPSERVICE_MAIN_FUNCTIONW lpServiceProc;
154 } SERVICE_TABLE_ENTRYW, *LPSERVICE_TABLE_ENTRYW;
156 DECL_WINELIB_TYPE_AW(SERVICE_TABLE_ENTRY)
157 DECL_WINELIB_TYPE_AW(LPSERVICE_TABLE_ENTRY)
159 /* Service status enumeration structure */
161 typedef struct _ENUM_SERVICE_STATUSA {
162 LPSTR lpServiceName;
163 LPSTR lpDisplayName;
164 SERVICE_STATUS ServiceStatus;
165 } ENUM_SERVICE_STATUSA, *LPENUM_SERVICE_STATUSA;
167 typedef struct _ENUM_SERVICE_STATUSW {
168 LPWSTR lpServiceName;
169 LPWSTR lpDisplayName;
170 SERVICE_STATUS ServiceStatus;
171 } ENUM_SERVICE_STATUSW, *LPENUM_SERVICE_STATUSW;
173 DECL_WINELIB_TYPE_AW(ENUM_SERVICE_STATUS)
174 DECL_WINELIB_TYPE_AW(LPENUM_SERVICE_STATUS)
176 typedef struct _QUERY_SERVICE_CONFIGA {
177 DWORD dwServiceType;
178 DWORD dwStartType;
179 DWORD dwErrorControl;
180 LPSTR lpBinaryPathName;
181 LPSTR lpLoadOrderGroup;
182 DWORD dwTagId;
183 LPSTR lpDependencies;
184 LPSTR lpServiceStartName;
185 LPSTR lpDisplayName;
186 } QUERY_SERVICE_CONFIGA, *LPQUERY_SERVICE_CONFIGA;
188 typedef struct _QUERY_SERVICE_CONFIGW {
189 DWORD dwServiceType;
190 DWORD dwStartType;
191 DWORD dwErrorControl;
192 LPWSTR lpBinaryPathName;
193 LPWSTR lpLoadOrderGroup;
194 DWORD dwTagId;
195 LPWSTR lpDependencies;
196 LPWSTR lpServiceStartName;
197 LPWSTR lpDisplayName;
198 } QUERY_SERVICE_CONFIGW, *LPQUERY_SERVICE_CONFIGW;
200 /* defines and structures for ChangeServiceConfig2 */
201 #define SERVICE_CONFIG_DESCRIPTION 1
202 #define SERVICE_CONFIG_FAILURE_ACTIONS 2
204 typedef struct _SERVICE_DESCRIPTIONA {
205 LPSTR lpDescription;
206 } SERVICE_DESCRIPTIONA,*LPSERVICE_DESCRIPTIONA;
208 typedef struct _SERVICE_DESCRIPTIONW {
209 LPWSTR lpDescription;
210 } SERVICE_DESCRIPTIONW,*LPSERVICE_DESCRIPTIONW;
212 DECL_WINELIB_TYPE_AW(SERVICE_DESCRIPTION)
213 DECL_WINELIB_TYPE_AW(LPSERVICE_DESCRIPTION)
215 typedef enum _SC_ACTION_TYPE {
216 SC_ACTION_NONE = 0,
217 SC_ACTION_RESTART = 1,
218 SC_ACTION_REBOOT = 2,
219 SC_ACTION_RUN_COMMAND = 3
220 } SC_ACTION_TYPE;
222 typedef struct _SC_ACTION {
223 SC_ACTION_TYPE Type;
224 DWORD Delay;
225 } SC_ACTION,*LPSC_ACTION;
227 typedef struct _SERVICE_FAILURE_ACTIONSA {
228 DWORD dwResetPeriod;
229 LPSTR lpRebootMsg;
230 LPSTR lpCommand;
231 DWORD cActions;
232 SC_ACTION * lpsaActions;
233 } SERVICE_FAILURE_ACTIONSA,*LPSERVICE_FAILURE_ACTIONSA;
235 typedef struct _SERVICE_FAILURE_ACTIONSW {
236 DWORD dwResetPeriod;
237 LPWSTR lpRebootMsg;
238 LPWSTR lpCommand;
239 DWORD cActions;
240 SC_ACTION * lpsaActions;
241 } SERVICE_FAILURE_ACTIONSW,*LPSERVICE_FAILURE_ACTIONSW;
243 DECL_WINELIB_TYPE_AW(SERVICE_FAILURE_ACTIONS)
244 DECL_WINELIB_TYPE_AW(LPSERVICE_FAILURE_ACTIONS)
246 typedef struct _QUERY_SERVICE_LOCK_STATUSA
248 DWORD fIsLocked;
249 LPSTR lpLockOwner;
250 DWORD dwLockDuration;
251 } QUERY_SERVICE_LOCK_STATUSA, *LPQUERY_SERVICE_LOCK_STATUSA;
253 typedef struct _QUERY_SERVICE_LOCK_STATUSW
255 DWORD fIsLocked;
256 LPWSTR lpLockOwner;
257 DWORD dwLockDuration;
258 } QUERY_SERVICE_LOCK_STATUSW, *LPQUERY_SERVICE_LOCK_STATUSW;
260 DECL_WINELIB_TYPE_AW(QUERY_SERVICE_LOCK_STATUS)
262 /* Service control handler function prototype */
264 typedef VOID (WINAPI *LPHANDLER_FUNCTION)(DWORD);
265 typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD,DWORD,LPVOID,LPVOID);
267 /* API function prototypes */
269 BOOL WINAPI ChangeServiceConfigA(SC_HANDLE,DWORD,DWORD,DWORD,LPCSTR,LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR,LPCSTR);
270 BOOL WINAPI ChangeServiceConfigW(SC_HANDLE,DWORD,DWORD,DWORD,LPCWSTR,LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR);
271 #define ChangeServiceConfig WINELIB_NAME_AW(ChangeServiceConfig)
272 BOOL WINAPI ChangeServiceConfig2A(SC_HANDLE,DWORD,LPVOID);
273 BOOL WINAPI ChangeServiceConfig2W(SC_HANDLE,DWORD,LPVOID);
274 #define ChangeServiceConfig2 WINELIB_NAME_AW(ChangeServiceConfig2)
275 BOOL WINAPI CloseServiceHandle(SC_HANDLE);
276 BOOL WINAPI ControlService(SC_HANDLE,DWORD,LPSERVICE_STATUS);
277 SC_HANDLE WINAPI CreateServiceA(SC_HANDLE,LPCSTR,LPCSTR,DWORD,DWORD,DWORD,DWORD,LPCSTR,
278 LPCSTR,LPDWORD,LPCSTR,LPCSTR,LPCSTR);
279 SC_HANDLE WINAPI CreateServiceW(SC_HANDLE,LPCWSTR,LPCWSTR,DWORD,DWORD,DWORD,DWORD,LPCWSTR,
280 LPCWSTR,LPDWORD,LPCWSTR,LPCWSTR,LPCWSTR);
281 #define CreateService WINELIB_NAME_AW(CreateService)
282 BOOL WINAPI DeleteService(SC_HANDLE);
283 BOOL WINAPI EnumDependentServicesA(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSA,DWORD,LPDWORD,LPDWORD);
284 BOOL WINAPI EnumDependentServicesW(SC_HANDLE,DWORD,LPENUM_SERVICE_STATUSW,DWORD,LPDWORD,LPDWORD);
285 #define EnumDependentServices WINELIB_NAME_AW(EnumDependentServices)
286 BOOL WINAPI EnumServicesStatusA(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSA,
287 DWORD,LPDWORD,LPDWORD,LPDWORD);
288 BOOL WINAPI EnumServicesStatusW(SC_HANDLE,DWORD,DWORD,LPENUM_SERVICE_STATUSW,
289 DWORD,LPDWORD,LPDWORD,LPDWORD);
290 #define EnumServicesStatus WINELIB_NAME_AW(EnumServicesStatus)
291 BOOL WINAPI GetServiceDisplayNameA(SC_HANDLE,LPCSTR,LPSTR,LPDWORD);
292 BOOL WINAPI GetServiceDisplayNameW(SC_HANDLE,LPCWSTR,LPWSTR,LPDWORD);
293 #define GetServiceDisplayName WINELIB_NAME_AW(GetServiceDisplayName)
294 BOOL WINAPI GetServiceKeyNameA(SC_HANDLE,LPCSTR,LPSTR,LPDWORD);
295 BOOL WINAPI GetServiceKeyNameW(SC_HANDLE,LPCWSTR,LPWSTR,LPDWORD);
296 #define GetServiceKeyName WINELIB_NAME_AW(GetServiceKeyName)
297 SC_LOCK WINAPI LockServiceDatabase(SC_HANDLE);
298 SC_HANDLE WINAPI OpenSCManagerA(LPCSTR,LPCSTR,DWORD);
299 SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR,LPCWSTR,DWORD);
300 #define OpenSCManager WINELIB_NAME_AW(OpenSCManager)
301 SC_HANDLE WINAPI OpenServiceA(SC_HANDLE,LPCSTR,DWORD);
302 SC_HANDLE WINAPI OpenServiceW(SC_HANDLE,LPCWSTR,DWORD);
303 #define OpenService WINELIB_NAME_AW(OpenService)
304 BOOL WINAPI QueryServiceStatus(SC_HANDLE,LPSERVICE_STATUS);
305 BOOL WINAPI QueryServiceStatusEx(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD);
306 BOOL WINAPI QueryServiceConfigA(SC_HANDLE,LPQUERY_SERVICE_CONFIGA,DWORD,LPDWORD);
307 BOOL WINAPI QueryServiceConfigW(SC_HANDLE,LPQUERY_SERVICE_CONFIGW,DWORD,LPDWORD);
308 #define QueryServiceConfig WINELIB_NAME_AW(QueryServiceConfig)
309 BOOL WINAPI QueryServiceLockStatusA(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSA,DWORD,LPDWORD);
310 BOOL WINAPI QueryServiceLockStatusW(SC_HANDLE,LPQUERY_SERVICE_LOCK_STATUSW,DWORD,LPDWORD);
311 #define QueryServiceLockStatus WINELIB_NAME_AW(QueryServiceLockStatus)
312 BOOL WINAPI QueryServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,DWORD,LPDWORD);
313 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA(LPCSTR,LPHANDLER_FUNCTION);
314 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(LPCWSTR,LPHANDLER_FUNCTION);
315 #define RegisterServiceCtrlHandler WINELIB_NAME_AW(RegisterServiceCtrlHandler)
316 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA(LPCSTR,LPHANDLER_FUNCTION_EX,LPVOID);
317 SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(LPCWSTR,LPHANDLER_FUNCTION_EX,LPVOID);
318 #define RegisterServiceCtrlHandlerEx WINELIB_NAME_AW(RegisterServiceCtrlHandlerEx)
319 BOOL WINAPI SetServiceObjectSecurity(SC_HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR);
320 BOOL WINAPI SetServiceStatus(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
321 BOOL WINAPI StartServiceA(SC_HANDLE,DWORD,LPCSTR*);
322 BOOL WINAPI StartServiceW(SC_HANDLE,DWORD,LPCWSTR*);
323 #define StartService WINELIB_NAME_AW(StartService)
324 BOOL WINAPI StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA);
325 BOOL WINAPI StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW);
326 #define StartServiceCtrlDispatcher WINELIB_NAME_AW(StartServiceCtrlDispatcher)
327 BOOL WINAPI UnlockServiceDatabase(SC_LOCK);
329 #ifdef __cplusplus
330 } /* extern "C" */
331 #endif /* defined(__cplusplus) */
333 #endif /* !defined(__WINE_WINSVC_H) */