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
24 #endif /* defined(__cplusplus) */
26 /* Service database names */
27 #define SERVICES_ACTIVE_DATABASEA "ServicesActive"
28 #define SERVICES_FAILED_DATABASEA "ServicesFailed"
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"
38 #define SERVICES_ACTIVE_DATABASE WINELIB_NAME_AW( SERVICES_ACTIVE_DATABASE )
39 #define SERVICES_FAILED_DATABASE WINELIB_NAME_AW( SERVICES_FAILED_DATABASE )
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
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 | \
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 | \
108 SERVICE_PAUSE_CONTINUE | \
109 SERVICE_INTERROGATE | \
110 SERVICE_USER_DEFINED_CONTROL )
112 #define SERVICE_NO_CHANGE 0xffffffff
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
{
126 DWORD dwCurrentState
;
127 DWORD dwControlsAccepted
;
128 DWORD dwWin32ExitCode
;
129 DWORD dwServiceSpecificExitCode
;
132 } SERVICE_STATUS
, *LPSERVICE_STATUS
;
134 typedef enum _SC_STATUS_TYPE
{
135 SC_STATUS_PROCESS_INFO
= 0
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
{
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
{
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 typedef enum _SC_ENUM_TYPE
{
174 SC_ENUM_PROCESS_INFO
= 0
177 DECL_WINELIB_TYPE_AW(ENUM_SERVICE_STATUS
)
178 DECL_WINELIB_TYPE_AW(LPENUM_SERVICE_STATUS
)
180 typedef struct _QUERY_SERVICE_CONFIGA
{
183 DWORD dwErrorControl
;
184 LPSTR lpBinaryPathName
;
185 LPSTR lpLoadOrderGroup
;
187 LPSTR lpDependencies
;
188 LPSTR lpServiceStartName
;
190 } QUERY_SERVICE_CONFIGA
, *LPQUERY_SERVICE_CONFIGA
;
192 typedef struct _QUERY_SERVICE_CONFIGW
{
195 DWORD dwErrorControl
;
196 LPWSTR lpBinaryPathName
;
197 LPWSTR lpLoadOrderGroup
;
199 LPWSTR lpDependencies
;
200 LPWSTR lpServiceStartName
;
201 LPWSTR lpDisplayName
;
202 } QUERY_SERVICE_CONFIGW
, *LPQUERY_SERVICE_CONFIGW
;
204 /* defines and structures for ChangeServiceConfig2 */
205 #define SERVICE_CONFIG_DESCRIPTION 1
206 #define SERVICE_CONFIG_FAILURE_ACTIONS 2
208 typedef struct _SERVICE_DESCRIPTIONA
{
210 } SERVICE_DESCRIPTIONA
,*LPSERVICE_DESCRIPTIONA
;
212 typedef struct _SERVICE_DESCRIPTIONW
{
213 LPWSTR lpDescription
;
214 } SERVICE_DESCRIPTIONW
,*LPSERVICE_DESCRIPTIONW
;
216 DECL_WINELIB_TYPE_AW(SERVICE_DESCRIPTION
)
217 DECL_WINELIB_TYPE_AW(LPSERVICE_DESCRIPTION
)
219 typedef enum _SC_ACTION_TYPE
{
221 SC_ACTION_RESTART
= 1,
222 SC_ACTION_REBOOT
= 2,
223 SC_ACTION_RUN_COMMAND
= 3
226 typedef struct _SC_ACTION
{
229 } SC_ACTION
,*LPSC_ACTION
;
231 typedef struct _SERVICE_FAILURE_ACTIONSA
{
236 SC_ACTION
* lpsaActions
;
237 } SERVICE_FAILURE_ACTIONSA
,*LPSERVICE_FAILURE_ACTIONSA
;
239 typedef struct _SERVICE_FAILURE_ACTIONSW
{
244 SC_ACTION
* lpsaActions
;
245 } SERVICE_FAILURE_ACTIONSW
,*LPSERVICE_FAILURE_ACTIONSW
;
247 DECL_WINELIB_TYPE_AW(SERVICE_FAILURE_ACTIONS
)
248 DECL_WINELIB_TYPE_AW(LPSERVICE_FAILURE_ACTIONS
)
250 typedef struct _QUERY_SERVICE_LOCK_STATUSA
254 DWORD dwLockDuration
;
255 } QUERY_SERVICE_LOCK_STATUSA
, *LPQUERY_SERVICE_LOCK_STATUSA
;
257 typedef struct _QUERY_SERVICE_LOCK_STATUSW
261 DWORD dwLockDuration
;
262 } QUERY_SERVICE_LOCK_STATUSW
, *LPQUERY_SERVICE_LOCK_STATUSW
;
264 DECL_WINELIB_TYPE_AW(QUERY_SERVICE_LOCK_STATUS
)
266 /* Service control handler function prototype */
268 typedef VOID (WINAPI
*LPHANDLER_FUNCTION
)(DWORD
);
269 typedef DWORD (WINAPI
*LPHANDLER_FUNCTION_EX
)(DWORD
,DWORD
,LPVOID
,LPVOID
);
271 /* API function prototypes */
273 BOOL WINAPI
ChangeServiceConfigA(SC_HANDLE
,DWORD
,DWORD
,DWORD
,LPCSTR
,LPCSTR
,LPDWORD
,LPCSTR
,LPCSTR
,LPCSTR
,LPCSTR
);
274 BOOL WINAPI
ChangeServiceConfigW(SC_HANDLE
,DWORD
,DWORD
,DWORD
,LPCWSTR
,LPCWSTR
,LPDWORD
,LPCWSTR
,LPCWSTR
,LPCWSTR
,LPCWSTR
);
275 #define ChangeServiceConfig WINELIB_NAME_AW(ChangeServiceConfig)
276 BOOL WINAPI
ChangeServiceConfig2A(SC_HANDLE
,DWORD
,LPVOID
);
277 BOOL WINAPI
ChangeServiceConfig2W(SC_HANDLE
,DWORD
,LPVOID
);
278 #define ChangeServiceConfig2 WINELIB_NAME_AW(ChangeServiceConfig2)
279 BOOL WINAPI
CloseServiceHandle(SC_HANDLE
);
280 BOOL WINAPI
ControlService(SC_HANDLE
,DWORD
,LPSERVICE_STATUS
);
281 SC_HANDLE WINAPI
CreateServiceA(SC_HANDLE
,LPCSTR
,LPCSTR
,DWORD
,DWORD
,DWORD
,DWORD
,LPCSTR
,
282 LPCSTR
,LPDWORD
,LPCSTR
,LPCSTR
,LPCSTR
);
283 SC_HANDLE WINAPI
CreateServiceW(SC_HANDLE
,LPCWSTR
,LPCWSTR
,DWORD
,DWORD
,DWORD
,DWORD
,LPCWSTR
,
284 LPCWSTR
,LPDWORD
,LPCWSTR
,LPCWSTR
,LPCWSTR
);
285 #define CreateService WINELIB_NAME_AW(CreateService)
286 BOOL WINAPI
DeleteService(SC_HANDLE
);
287 BOOL WINAPI
EnumDependentServicesA(SC_HANDLE
,DWORD
,LPENUM_SERVICE_STATUSA
,DWORD
,LPDWORD
,LPDWORD
);
288 BOOL WINAPI
EnumDependentServicesW(SC_HANDLE
,DWORD
,LPENUM_SERVICE_STATUSW
,DWORD
,LPDWORD
,LPDWORD
);
289 #define EnumDependentServices WINELIB_NAME_AW(EnumDependentServices)
290 BOOL WINAPI
EnumServicesStatusA(SC_HANDLE
,DWORD
,DWORD
,LPENUM_SERVICE_STATUSA
,
291 DWORD
,LPDWORD
,LPDWORD
,LPDWORD
);
292 BOOL WINAPI
EnumServicesStatusW(SC_HANDLE
,DWORD
,DWORD
,LPENUM_SERVICE_STATUSW
,
293 DWORD
,LPDWORD
,LPDWORD
,LPDWORD
);
294 #define EnumServicesStatus WINELIB_NAME_AW(EnumServicesStatus)
295 BOOL WINAPI
GetServiceDisplayNameA(SC_HANDLE
,LPCSTR
,LPSTR
,LPDWORD
);
296 BOOL WINAPI
GetServiceDisplayNameW(SC_HANDLE
,LPCWSTR
,LPWSTR
,LPDWORD
);
297 #define GetServiceDisplayName WINELIB_NAME_AW(GetServiceDisplayName)
298 BOOL WINAPI
GetServiceKeyNameA(SC_HANDLE
,LPCSTR
,LPSTR
,LPDWORD
);
299 BOOL WINAPI
GetServiceKeyNameW(SC_HANDLE
,LPCWSTR
,LPWSTR
,LPDWORD
);
300 #define GetServiceKeyName WINELIB_NAME_AW(GetServiceKeyName)
301 SC_LOCK WINAPI
LockServiceDatabase(SC_HANDLE
);
302 BOOL WINAPI
NotifyBootConfigStatus(BOOL
);
303 SC_HANDLE WINAPI
OpenSCManagerA(LPCSTR
,LPCSTR
,DWORD
);
304 SC_HANDLE WINAPI
OpenSCManagerW(LPCWSTR
,LPCWSTR
,DWORD
);
305 #define OpenSCManager WINELIB_NAME_AW(OpenSCManager)
306 SC_HANDLE WINAPI
OpenServiceA(SC_HANDLE
,LPCSTR
,DWORD
);
307 SC_HANDLE WINAPI
OpenServiceW(SC_HANDLE
,LPCWSTR
,DWORD
);
308 #define OpenService WINELIB_NAME_AW(OpenService)
309 BOOL WINAPI
QueryServiceStatus(SC_HANDLE
,LPSERVICE_STATUS
);
310 BOOL WINAPI
QueryServiceStatusEx(SC_HANDLE
,SC_STATUS_TYPE
,LPBYTE
,DWORD
,LPDWORD
);
311 BOOL WINAPI
QueryServiceConfigA(SC_HANDLE
,LPQUERY_SERVICE_CONFIGA
,DWORD
,LPDWORD
);
312 BOOL WINAPI
QueryServiceConfigW(SC_HANDLE
,LPQUERY_SERVICE_CONFIGW
,DWORD
,LPDWORD
);
313 #define QueryServiceConfig WINELIB_NAME_AW(QueryServiceConfig)
314 BOOL WINAPI
QueryServiceLockStatusA(SC_HANDLE
,LPQUERY_SERVICE_LOCK_STATUSA
,DWORD
,LPDWORD
);
315 BOOL WINAPI
QueryServiceLockStatusW(SC_HANDLE
,LPQUERY_SERVICE_LOCK_STATUSW
,DWORD
,LPDWORD
);
316 #define QueryServiceLockStatus WINELIB_NAME_AW(QueryServiceLockStatus)
317 BOOL WINAPI
QueryServiceObjectSecurity(SC_HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
,DWORD
,LPDWORD
);
318 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerA(LPCSTR
,LPHANDLER_FUNCTION
);
319 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerW(LPCWSTR
,LPHANDLER_FUNCTION
);
320 #define RegisterServiceCtrlHandler WINELIB_NAME_AW(RegisterServiceCtrlHandler)
321 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerExA(LPCSTR
,LPHANDLER_FUNCTION_EX
,LPVOID
);
322 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerExW(LPCWSTR
,LPHANDLER_FUNCTION_EX
,LPVOID
);
323 #define RegisterServiceCtrlHandlerEx WINELIB_NAME_AW(RegisterServiceCtrlHandlerEx)
324 BOOL WINAPI
SetServiceObjectSecurity(SC_HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
);
325 BOOL WINAPI
SetServiceStatus(SERVICE_STATUS_HANDLE
,LPSERVICE_STATUS
);
326 BOOL WINAPI
StartServiceA(SC_HANDLE
,DWORD
,LPCSTR
*);
327 BOOL WINAPI
StartServiceW(SC_HANDLE
,DWORD
,LPCWSTR
*);
328 #define StartService WINELIB_NAME_AW(StartService)
329 BOOL WINAPI
StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA
);
330 BOOL WINAPI
StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW
);
331 #define StartServiceCtrlDispatcher WINELIB_NAME_AW(StartServiceCtrlDispatcher)
332 BOOL WINAPI
UnlockServiceDatabase(SC_LOCK
);
336 #endif /* defined(__cplusplus) */
338 #endif /* !defined(__WINE_WINSVC_H) */