1 #ifndef W32_SVRAPI_H_INCLUDED
2 #define W32_SVRAPI_H_INCLUDED
3 #define W32_SVRAPI_H_VERSION "$Id: w32svrapi.h,v 1.2 2009/05/16 13:27:20 fabiankeil Exp $"
4 /*********************************************************************
6 * File : $Source: /cvsroot/ijbswa/current/w32svrapi.h,v $
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.
50 *********************************************************************/
60 extern char szThisServiceName[];
61 extern BOOL bRunAsService;
62 extern SERVICE_TABLE_ENTRY w32ServiceDispatchTable[];
64 extern BOOL install_service(const char *service_name);
65 extern BOOL uninstall_service(const char *service_name);
66 extern void w32_service_exit_notify(void);
67 extern void w32_set_service_cwd(void);
68 extern void w32_service_listen_loop(void *p);
71 extern BOOL CanSystemSupportServices();
74 extern SC_HANDLE w32_open_sc_manager(
75 LPCTSTR lpMachineName, /* computer name */
76 LPCTSTR lpDatabaseName, /* SCM database name */
77 DWORD dwDesiredAccess); /* access type */
80 extern BOOL w32_close_service_handle(
81 SC_HANDLE hSCObject); /* handle to service or SCM object */
84 extern SC_HANDLE w32_open_service(
85 SC_HANDLE hSCManager, /* handle to SCM database */
86 LPCTSTR lpServiceName, /* service name */
87 DWORD dwDesiredAccess); /* access */
90 extern SC_HANDLE w32_create_service(
91 SC_HANDLE hSCManager, /* handle to SCM database */
92 LPCTSTR lpServiceName, /* name of service to start */
93 LPCTSTR lpDisplayName, /* display name */
94 DWORD dwDesiredAccess, /* type of access to service */
95 DWORD dwServiceType, /* type of service */
96 DWORD dwStartType, /* when to start service */
97 DWORD dwErrorControl, /* severity of service failure */
98 LPCTSTR lpBinaryPathName, /* name of binary file */
99 LPCTSTR lpLoadOrderGroup, /* name of load ordering group */
100 LPDWORD lpdwTagId, /* tag identifier */
101 LPCTSTR lpDependencies, /* array of dependency names */
102 LPCTSTR lpServiceStartName, /* account name */
103 LPCTSTR lpPassword); /* account password */
106 extern BOOL w32_delete_service(
107 SC_HANDLE hService); /* handle to service */
110 extern BOOL w32_query_service_config(
111 SC_HANDLE hService, /* handle to service */
112 LPQUERY_SERVICE_CONFIG lpServiceConfig, /* buffer */
113 DWORD cbBufSize, /* size of buffer */
114 LPDWORD pcbBytesNeeded); /* bytes needed */
117 extern BOOL w32_start_service_ctrl_dispatcher(
118 CONST LPSERVICE_TABLE_ENTRY lpServiceTable); /* service table */
121 extern SERVICE_STATUS_HANDLE w32_register_service_ctrl_handler(
122 LPCTSTR lpServiceName, /* service name */
123 LPHANDLER_FUNCTION lpHandlerProc); /* handler function */
126 extern BOOL w32_set_service_status(
127 SERVICE_STATUS_HANDLE hServiceStatus, /* service status handle */
128 LPSERVICE_STATUS lpServiceStatus); /* status buffer */
131 #endif /* def _WIN32 */
138 #endif /* ndef W32_SVRAPI_H_INCLUDED */