1 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
2 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
3 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
6 // Copyright (C) 1993-1997 Microsoft Corporation. All Rights Reserved.
13 // Comments: The use of this header file and the accompanying service.c
14 // file simplifies the process of writting a service. You as a developer
15 // simply need to follow the TODO's outlined in this header file, and
16 // implement the ServiceStart() and ServiceStop() functions.
18 // There is no need to modify the code in service.c. Just add service.c
19 // to your project and link with the following libraries...
21 // libcmt.lib kernel32.lib advapi.lib shell32.lib
23 // This code also supports unicode. Be sure to compile both service.c and
24 // and code #include "service.h" with the same Unicode setting.
26 // Upon completion, your code will have the following command line interface
28 // <service exe> -? to display this list
29 // <service exe> -install to install the service
30 // <service exe> -remove to remove the service
31 // <service exe> -debug <params> to run as a console app for debugging
33 // Note: This code also implements Ctrl+C and Ctrl+Break handlers
34 // when using the debug option. These console events cause
35 // your ServiceStop routine to be called
37 // Also, this code only handles the OWN_SERVICE service type
38 // running in the LOCAL_SYSTEM security context.
40 // To control your service ( start, stop, etc ) you may use the
41 // Services control panel applet or the NET.EXE program.
43 // To aid in writing/debugging service, the
44 // SDK contains a utility (MSTOOLS\BIN\SC.EXE) that
45 // can be used to control, configure, or obtain service status.
46 // SC displays complete status for any service/driver
47 // in the service database, and allows any of the configuration
48 // parameters to be easily changed at the command line.
49 // For more information on SC.EXE, type SC at the command line.
53 * modified Mar.07, 2002 by Feng Qin <fqin@ncsa.uiuc.edu>
56 * removed some functions we don't use at all
57 * add code to start the service immediately after service is installed
59 * $Id: service.h,v 1.1.1.1 2004/05/18 01:50:44 kgibbs Exp $
71 //////////////////////////////////////////////////////////////////////////////
72 //// todo: change to desired strings
74 // name of the executable
75 #define SZAPPNAME "IPerf"
77 // internal name of the service
78 #define SZSERVICENAME "IPerfService"
80 // displayed name of the service
81 #define SZSERVICEDISPLAYNAME "IPerf Service"
83 // list of service dependencies - "dep1\0dep2\0\0"
84 #define SZDEPENDENCIES ""
86 //////////////////////////////////////////////////////////////////////////////
90 //////////////////////////////////////////////////////////////////////////////
91 //// todo: ServiceStart()must be defined by in your code.
92 //// The service should use ReportStatusToSCMgr to indicate
93 //// progress. This routine must also be used by StartService()
94 //// to report to the SCM when the service is running.
96 //// If a ServiceStop procedure is going to take longer than
97 //// 3 seconds to execute, it should spawn a thread to
98 //// execute the stop code, and return. Otherwise, the
99 //// ServiceControlManager will believe that the service has
100 //// stopped responding
102 VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
104 //////////////////////////////////////////////////////////////////////////////
106 VOID WINAPI service_ctrl(DWORD dwCtrlCode);
107 VOID WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv);
108 VOID CmdInstallService(int argc, char **argv);
109 BOOL CmdRemoveService();
110 BOOL CmdStartService(int argc, char **argv);
111 LPTSTR GetLastErrorText( LPTSTR lpszBuf, DWORD dwSize );
112 VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv);
115 //////////////////////////////////////////////////////////////////////////////
116 //// The following are procedures which
117 //// may be useful to call within the above procedures,
118 //// but require no implementation by the user.
119 //// They are implemented in service.c
122 // FUNCTION: ReportStatusToSCMgr()
124 // PURPOSE: Sets the current status of the service and
125 // reports it to the Service Control Manager
128 // dwCurrentState - the state of the service
129 // dwWin32ExitCode - error code to report
130 // dwWaitHint - worst case estimate to next checkpoint
136 BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
140 // FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
142 // PURPOSE: Allows any thread to log an error message
145 // lpszMsg - text for message
150 void AddToMessageLog(LPTSTR lpszMsg);
151 //////////////////////////////////////////////////////////////////////////////