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
57 #define SERVICE_STOPPED 0x00000001
58 #define SERVICE_START_PENDING 0x00000002
59 #define SERVICE_STOP_PENDING 0x00000003
60 #define SERVICE_RUNNING 0x00000004
61 #define SERVICE_CONTINUE_PENDING 0x00000005
62 #define SERVICE_PAUSE_PENDING 0x00000006
63 #define SERVICE_PAUSED 0x00000007
65 /* Controls Accepted */
66 #define SERVICE_ACCEPT_STOP 0x00000001
67 #define SERVICE_ACCEPT_PAUSE_CONTINUE 0x00000002
68 #define SERVICE_ACCEPT_SHUTDOWN 0x00000004
69 #define SERVICE_ACCEPT_PARAMCHANGE 0x00000008
70 #define SERVICE_ACCEPT_NETBINDCHANGE 0x00000010
71 #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE 0x00000020
72 #define SERVICE_ACCEPT_POWEREVENT 0x00000040
74 /* Service Control Manager Object access types */
75 #define SC_MANAGER_CONNECT 0x0001
76 #define SC_MANAGER_CREATE_SERVICE 0x0002
77 #define SC_MANAGER_ENUMERATE_SERVICE 0x0004
78 #define SC_MANAGER_LOCK 0x0008
79 #define SC_MANAGER_QUERY_LOCK_STATUS 0x0010
80 #define SC_MANAGER_MODIFY_BOOT_CONFIG 0x0020
81 #define SC_MANAGER_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | \
82 SC_MANAGER_CONNECT | \
83 SC_MANAGER_CREATE_SERVICE | \
84 SC_MANAGER_ENUMERATE_SERVICE | \
86 SC_MANAGER_QUERY_LOCK_STATUS | \
87 SC_MANAGER_MODIFY_BOOT_CONFIG )
89 #define SERVICE_QUERY_CONFIG 0x0001
90 #define SERVICE_CHANGE_CONFIG 0x0002
91 #define SERVICE_QUERY_STATUS 0x0004
92 #define SERVICE_ENUMERATE_DEPENDENTS 0x0008
93 #define SERVICE_START 0x0010
94 #define SERVICE_STOP 0x0020
95 #define SERVICE_PAUSE_CONTINUE 0x0040
96 #define SERVICE_INTERROGATE 0x0080
97 #define SERVICE_USER_DEFINED_CONTROL 0x0100
99 #define SERVICE_ALL_ACCESS ( STANDARD_RIGHTS_REQUIRED | \
100 SERVICE_QUERY_CONFIG | \
101 SERVICE_CHANGE_CONFIG | \
102 SERVICE_QUERY_STATUS | \
103 SERVICE_ENUMERATE_DEPENDENTS | \
106 SERVICE_PAUSE_CONTINUE | \
107 SERVICE_INTERROGATE | \
108 SERVICE_USER_DEFINED_CONTROL )
110 #define SERVICE_NO_CHANGE 0xffffffff
115 typedef HANDLE SC_HANDLE
, *LPSC_HANDLE
;
116 typedef DWORD SERVICE_STATUS_HANDLE
;
119 /* Service status structure */
121 typedef struct _SERVICE_STATUS
{
123 DWORD dwCurrentState
;
124 DWORD dwControlsAccepted
;
125 DWORD dwWin32ExitCode
;
126 DWORD dwServiceSpecificExitCode
;
129 } SERVICE_STATUS
, *LPSERVICE_STATUS
;
131 typedef enum _SC_STATUS_TYPE
{
132 SC_STATUS_PROCESS_INFO
= 0
135 /* Service main function prototype */
137 typedef VOID (CALLBACK
*LPSERVICE_MAIN_FUNCTIONA
)(DWORD
,LPSTR
*);
138 typedef VOID (CALLBACK
*LPSERVICE_MAIN_FUNCTIONW
)(DWORD
,LPWSTR
*);
139 DECL_WINELIB_TYPE_AW(LPSERVICE_MAIN_FUNCTION
)
141 /* Service start table */
143 typedef struct _SERVICE_TABLE_ENTRYA
{
145 LPSERVICE_MAIN_FUNCTIONA lpServiceProc
;
146 } SERVICE_TABLE_ENTRYA
, *LPSERVICE_TABLE_ENTRYA
;
148 typedef struct _SERVICE_TABLE_ENTRYW
{
149 LPWSTR lpServiceName
;
150 LPSERVICE_MAIN_FUNCTIONW lpServiceProc
;
151 } SERVICE_TABLE_ENTRYW
, *LPSERVICE_TABLE_ENTRYW
;
153 DECL_WINELIB_TYPE_AW(SERVICE_TABLE_ENTRY
)
154 DECL_WINELIB_TYPE_AW(LPSERVICE_TABLE_ENTRY
)
156 /* Service status enumeration structure */
158 typedef struct _ENUM_SERVICE_STATUSA
{
161 SERVICE_STATUS ServiceStatus
;
162 } ENUM_SERVICE_STATUSA
, *LPENUM_SERVICE_STATUSA
;
164 typedef struct _ENUM_SERVICE_STATUSW
{
165 LPWSTR lpServiceName
;
166 LPWSTR lpDisplayName
;
167 SERVICE_STATUS ServiceStatus
;
168 } ENUM_SERVICE_STATUSW
, *LPENUM_SERVICE_STATUSW
;
170 DECL_WINELIB_TYPE_AW(ENUM_SERVICE_STATUS
)
171 DECL_WINELIB_TYPE_AW(LPENUM_SERVICE_STATUS
)
173 typedef struct _QUERY_SERVICE_CONFIGA
{
176 DWORD dwErrorControl
;
177 LPSTR lpBinaryPathName
;
178 LPSTR lpLoadOrderGroup
;
180 LPSTR lpDependencies
;
181 LPSTR lpServiceStartName
;
183 } QUERY_SERVICE_CONFIGA
, *LPQUERY_SERVICE_CONFIGA
;
185 typedef struct _QUERY_SERVICE_CONFIGW
{
188 DWORD dwErrorControl
;
189 LPWSTR lpBinaryPathName
;
190 LPWSTR lpLoadOrderGroup
;
192 LPWSTR lpDependencies
;
193 LPWSTR lpServiceStartName
;
194 LPWSTR lpDisplayName
;
195 } QUERY_SERVICE_CONFIGW
, *LPQUERY_SERVICE_CONFIGW
;
197 /* defines and structures for ChangeServiceConfig2 */
198 #define SERVICE_CONFIG_DESCRIPTION 1
199 #define SERVICE_CONFIG_FAILURE_ACTIONS 2
201 typedef struct _SERVICE_DESCRIPTIONA
{
203 } SERVICE_DESCRIPTIONA
,*LPSERVICE_DESCRIPTIONA
;
205 typedef struct _SERVICE_DESCRIPTIONW
{
206 LPWSTR lpDescription
;
207 } SERVICE_DESCRIPTIONW
,*LPSERVICE_DESCRIPTIONW
;
209 DECL_WINELIB_TYPE_AW(SERVICE_DESCRIPTION
)
210 DECL_WINELIB_TYPE_AW(LPSERVICE_DESCRIPTION
)
212 typedef enum _SC_ACTION_TYPE
{
214 SC_ACTION_RESTART
= 1,
215 SC_ACTION_REBOOT
= 2,
216 SC_ACTION_RUN_COMMAND
= 3
219 typedef struct _SC_ACTION
{
222 } SC_ACTION
,*LPSC_ACTION
;
224 typedef struct _SERVICE_FAILURE_ACTIONSA
{
229 SC_ACTION
* lpsaActions
;
230 } SERVICE_FAILURE_ACTIONSA
,*LPSERVICE_FAILURE_ACTIONSA
;
232 typedef struct _SERVICE_FAILURE_ACTIONSW
{
237 SC_ACTION
* lpsaActions
;
238 } SERVICE_FAILURE_ACTIONSW
,*LPSERVICE_FAILURE_ACTIONSW
;
240 DECL_WINELIB_TYPE_AW(SERVICE_FAILURE_ACTIONS
)
241 DECL_WINELIB_TYPE_AW(LPSERVICE_FAILURE_ACTIONS
)
243 /* Service control handler function prototype */
245 typedef VOID (WINAPI
*LPHANDLER_FUNCTION
)(DWORD
);
246 typedef DWORD (WINAPI
*LPHANDLER_FUNCTION_EX
)(DWORD
,DWORD
,LPVOID
,LPVOID
);
248 /* API function prototypes */
250 BOOL WINAPI
ChangeServiceConfigA(SC_HANDLE
,DWORD
,DWORD
,DWORD
,LPCSTR
,LPCSTR
,LPDWORD
,LPCSTR
,LPCSTR
,LPCSTR
,LPCSTR
);
251 BOOL WINAPI
ChangeServiceConfigW(SC_HANDLE
,DWORD
,DWORD
,DWORD
,LPCWSTR
,LPCWSTR
,LPDWORD
,LPCWSTR
,LPCWSTR
,LPCWSTR
,LPCWSTR
);
252 #define ChangeServiceConfig WINELIB_NAME_AW(ChangeServiceConfig)
253 BOOL WINAPI
ChangeServiceConfig2A(SC_HANDLE
,DWORD
,LPVOID
);
254 BOOL WINAPI
ChangeServiceConfig2W(SC_HANDLE
,DWORD
,LPVOID
);
255 #define ChangeServiceConfig2 WINELIB_NAME_AW(ChangeServiceConfig2)
256 BOOL WINAPI
CloseServiceHandle(SC_HANDLE
);
257 BOOL WINAPI
ControlService(SC_HANDLE
,DWORD
,LPSERVICE_STATUS
);
258 SC_HANDLE WINAPI
CreateServiceA(SC_HANDLE
,LPCSTR
,LPCSTR
,DWORD
,DWORD
,DWORD
,DWORD
,LPCSTR
,
259 LPCSTR
,LPDWORD
,LPCSTR
,LPCSTR
,LPCSTR
);
260 SC_HANDLE WINAPI
CreateServiceW(SC_HANDLE
,LPCWSTR
,LPCWSTR
,DWORD
,DWORD
,DWORD
,DWORD
,LPCWSTR
,
261 LPCWSTR
,LPDWORD
,LPCWSTR
,LPCWSTR
,LPCWSTR
);
262 #define CreateService WINELIB_NAME_AW(CreateService)
263 BOOL WINAPI
DeleteService(SC_HANDLE
);
264 BOOL WINAPI
EnumServicesStatusA(SC_HANDLE
,DWORD
,DWORD
,LPENUM_SERVICE_STATUSA
,
265 DWORD
,LPDWORD
,LPDWORD
,LPDWORD
);
266 BOOL WINAPI
EnumServicesStatusW(SC_HANDLE
,DWORD
,DWORD
,LPENUM_SERVICE_STATUSW
,
267 DWORD
,LPDWORD
,LPDWORD
,LPDWORD
);
268 #define EnumServicesStatus WINELIB_NAME_AW(EnumServicesStatus)
269 SC_HANDLE WINAPI
OpenSCManagerA(LPCSTR
,LPCSTR
,DWORD
);
270 SC_HANDLE WINAPI
OpenSCManagerW(LPCWSTR
,LPCWSTR
,DWORD
);
271 #define OpenSCManager WINELIB_NAME_AW(OpenSCManager)
272 SC_HANDLE WINAPI
OpenServiceA(SC_HANDLE
,LPCSTR
,DWORD
);
273 SC_HANDLE WINAPI
OpenServiceW(SC_HANDLE
,LPCWSTR
,DWORD
);
274 #define OpenService WINELIB_NAME_AW(OpenService)
275 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerA(LPCSTR
,LPHANDLER_FUNCTION
);
276 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerW(LPCWSTR
,LPHANDLER_FUNCTION
);
277 #define RegisterServiceCtrlHandler WINELIB_NAME_AW(RegisterServiceCtrlHandler)
278 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerExA(LPCSTR
,LPHANDLER_FUNCTION_EX
,LPVOID
);
279 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerExW(LPCWSTR
,LPHANDLER_FUNCTION_EX
,LPVOID
);
280 #define RegisterServiceCtrlHandlerEx WINELIB_NAME_AW(RegisterServiceCtrlHandlerEx)
281 BOOL WINAPI
SetServiceStatus(SERVICE_STATUS_HANDLE
,LPSERVICE_STATUS
);
282 BOOL WINAPI
StartServiceA(SC_HANDLE
,DWORD
,LPCSTR
*);
283 BOOL WINAPI
StartServiceW(SC_HANDLE
,DWORD
,LPCWSTR
*);
284 #define StartService WINELIB_NAME_AW(StartService)
285 BOOL WINAPI
StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA
);
286 BOOL WINAPI
StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW
);
287 #define StartServiceCtrlDispatcher WINELIB_NAME_AW(StartServiceCtrlDispatcher)
288 BOOL WINAPI
QueryServiceStatus(SC_HANDLE
,LPSERVICE_STATUS
);
289 BOOL WINAPI
QueryServiceStatusEx(SC_HANDLE
,SC_STATUS_TYPE
,LPBYTE
,DWORD
,LPDWORD
);
290 BOOL WINAPI
QueryServiceConfigA(SC_HANDLE
,LPQUERY_SERVICE_CONFIGA
,DWORD
,LPDWORD
);
291 BOOL WINAPI
QueryServiceConfigW(SC_HANDLE
,LPQUERY_SERVICE_CONFIGW
,DWORD
,LPDWORD
);
292 #define QueryServiceConfig WINELIB_NAME_AW(QueryServiceConfig)
296 #endif /* defined(__cplusplus) */
298 #endif /* !defined(__WINE_WINSVC_H) */