1 #ifndef W32_SVRAPI_H_INCLUDED
2 #define W32_SVRAPI_H_INCLUDED
3 #define W32_SVRAPI_H_VERSION "$Id$"
4 /*********************************************************************
8 * Purpose : Win32 Services API for Privoxy.
9 * Provides the implementation of an Win32 service to
10 * allow the code to directly register and run as a
11 * native Windows service application.
13 * Since Win9x/ME platforms don't provide or support
14 * running programs as services, this code uses runtime
15 * loading and calling of the Win32 Service API, to
16 * prevent the possibility of getting "entry point not
17 * found" type errors on unsupported platforms. This adds
18 * a little more complexity to the code, but it is worth
19 * doing to provide that isolation.
21 * Copyright : Written by and Copyright (C) 2003 members of
22 * the Privoxy team. http://www.privoxy.org/
24 * Written by and Copyright (C) 2003 Ian Cummings
25 * <ian_a_c@hotmail.com>
27 * Special thanks to Mates Dolák <matesek@post.cz> for
28 * some very helpful feedback and suggestions during the
29 * development of this code.
32 * This program is free software; you can redistribute it
33 * and/or modify it under the terms of the GNU General
34 * Public License as published by the Free Software
35 * Foundation; either version 2 of the License, or (at
36 * your option) any later version.
38 * This program is distributed in the hope that it will
39 * be useful, but WITHOUT ANY WARRANTY; without even the
40 * implied warranty of MERCHANTABILITY or FITNESS FOR A
41 * PARTICULAR PURPOSE. See the GNU General Public
42 * License for more details.
44 * The GNU General Public License should be included with
45 * this file. If not, you can view it at
46 * http://www.gnu.org/copyleft/gpl.html
47 * or write to the Free Software Foundation, Inc., 59
48 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
54 *********************************************************************/
64 extern char szThisServiceName[];
65 extern BOOL bRunAsService;
66 extern SERVICE_TABLE_ENTRY w32ServiceDispatchTable[];
68 extern BOOL install_service(const char *service_name);
69 extern BOOL uninstall_service(const char *service_name);
70 extern void w32_service_exit_notify(void);
71 extern void w32_set_service_cwd(void);
72 extern void w32_service_listen_loop(void *p);
75 extern BOOL CanSystemSupportServices();
78 extern SC_HANDLE w32_open_sc_manager(
79 LPCTSTR lpMachineName, /* computer name */
80 LPCTSTR lpDatabaseName, /* SCM database name */
81 DWORD dwDesiredAccess); /* access type */
84 extern BOOL w32_close_service_handle(
85 SC_HANDLE hSCObject); /* handle to service or SCM object */
88 extern SC_HANDLE w32_open_service(
89 SC_HANDLE hSCManager, /* handle to SCM database */
90 LPCTSTR lpServiceName, /* service name */
91 DWORD dwDesiredAccess); /* access */
94 extern SC_HANDLE w32_create_service(
95 SC_HANDLE hSCManager, /* handle to SCM database */
96 LPCTSTR lpServiceName, /* name of service to start */
97 LPCTSTR lpDisplayName, /* display name */
98 DWORD dwDesiredAccess, /* type of access to service */
99 DWORD dwServiceType, /* type of service */
100 DWORD dwStartType, /* when to start service */
101 DWORD dwErrorControl, /* severity of service failure */
102 LPCTSTR lpBinaryPathName, /* name of binary file */
103 LPCTSTR lpLoadOrderGroup, /* name of load ordering group */
104 LPDWORD lpdwTagId, /* tag identifier */
105 LPCTSTR lpDependencies, /* array of dependency names */
106 LPCTSTR lpServiceStartName, /* account name */
107 LPCTSTR lpPassword); /* account password */
110 extern BOOL w32_delete_service(
111 SC_HANDLE hService); /* handle to service */
114 extern BOOL w32_query_service_config(
115 SC_HANDLE hService, /* handle to service */
116 LPQUERY_SERVICE_CONFIG lpServiceConfig, /* buffer */
117 DWORD cbBufSize, /* size of buffer */
118 LPDWORD pcbBytesNeeded); /* bytes needed */
121 extern BOOL w32_start_service_ctrl_dispatcher(
122 CONST LPSERVICE_TABLE_ENTRY lpServiceTable); /* service table */
125 extern SERVICE_STATUS_HANDLE w32_register_service_ctrl_handler(
126 LPCTSTR lpServiceName, /* service name */
127 LPHANDLER_FUNCTION lpHandlerProc); /* handler function */
130 extern BOOL w32_set_service_status(
131 SERVICE_STATUS_HANDLE hServiceStatus, /* service status handle */
132 LPSERVICE_STATUS lpServiceStatus); /* status buffer */
135 #endif /* def _WIN32 */
142 #endif /* ndef W32_SVRAPI_H_INCLUDED */