00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 00004 // PARTICULAR PURPOSE. 00005 // 00006 // Copyright (C) 1993-1997 Microsoft Corporation. All Rights Reserved. 00007 // 00008 // MODULE: service.h 00009 // 00010 // AUTHOR: Craig Link 00011 // 00012 // 00013 // Comments: The use of this header file and the accompanying service.c 00014 // file simplifies the process of writting a service. You as a developer 00015 // simply need to follow the TODO's outlined in this header file, and 00016 // implement the ServiceStart() and ServiceStop() functions. 00017 // 00018 // There is no need to modify the code in service.c. Just add service.c 00019 // to your project and link with the following libraries... 00020 // 00021 // libcmt.lib kernel32.lib advapi.lib shell32.lib 00022 // 00023 // This code also supports unicode. Be sure to compile both service.c and 00024 // and code #include "service.h" with the same Unicode setting. 00025 // 00026 // Upon completion, your code will have the following command line interface 00027 // 00028 // <service exe> -? to display this list 00029 // <service exe> -install to install the service 00030 // <service exe> -remove to remove the service 00031 // <service exe> -debug <params> to run as a console app for debugging 00032 // 00033 // Note: This code also implements Ctrl+C and Ctrl+Break handlers 00034 // when using the debug option. These console events cause 00035 // your ServiceStop routine to be called 00036 // 00037 // Also, this code only handles the OWN_SERVICE service type 00038 // running in the LOCAL_SYSTEM security context. 00039 // 00040 // To control your service ( start, stop, etc ) you may use the 00041 // Services control panel applet or the NET.EXE program. 00042 // 00043 // To aid in writing/debugging service, the 00044 // SDK contains a utility (MSTOOLS\BIN\SC.EXE) that 00045 // can be used to control, configure, or obtain service status. 00046 // SC displays complete status for any service/driver 00047 // in the service database, and allows any of the configuration 00048 // parameters to be easily changed at the command line. 00049 // For more information on SC.EXE, type SC at the command line. 00050 // 00051 00052 #ifndef _SERVICE_H 00053 #define _SERVICE_H 00054 00055 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 00064 // name of the executable 00065 #define SZAPPNAME "sbhttpd" 00066 // internal name of the service 00067 #define SZSERVICENAME "sbhttpd" 00068 // displayed name of the service 00069 #define SZSERVICEDISPLAYNAME "ScriptBasic httpd server 1.0" 00070 // list of service dependencies - "dep1\0dep2\0\0" 00071 #define SZDEPENDENCIES "" 00072 00073 00074 00075 00088 VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv); 00089 VOID ServiceStop(); 00091 00092 00093 00099 00100 // 00101 // FUNCTION: ReportStatusToSCMgr() 00102 // 00103 // PURPOSE: Sets the current status of the service and 00104 // reports it to the Service Control Manager 00105 // 00106 // PARAMETERS: 00107 // dwCurrentState - the state of the service 00108 // dwWin32ExitCode - error code to report 00109 // dwWaitHint - worst case estimate to next checkpoint 00110 // 00111 // RETURN VALUE: 00112 // TRUE - success 00113 // FALSE - failure 00114 // 00115 BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint); 00116 00117 00118 // 00119 // FUNCTION: AddToMessageLog(LPTSTR lpszMsg) 00120 // 00121 // PURPOSE: Allows any thread to log an error message 00122 // 00123 // PARAMETERS: 00124 // lpszMsg - text for message 00125 // 00126 // RETURN VALUE: 00127 // none 00128 // 00129 void AddToMessageLog(LPTSTR lpszMsg); 00131 00132 00133 #ifdef __cplusplus 00134 } 00135 #endif 00136 00137 #endif