6 * *Windows Service related functions declaration
\r
7 * *By Raju Krishanppa(raju_krishnappa@yahoo.com)
\r
18 * * Define Constants for Register, De-register , Run As service or Console mode
\r
20 #define REGISTER_SERVICE 0
\r
21 #define UN_REGISTER_SERVICE 1
\r
22 #define RUN_AS_SERVICE 2
\r
23 #define RUN_AS_CONSOLE 3
\r
27 * * Define Message catalog ID
\r
28 * * MessageId: DISPLAY_MSG
\r
32 #define DISPLAY_MSG 0x00000064L
\r
36 * * Hint Value to SCM to wait before sending successive commands to service
\r
38 #define SCM_WAIT_INTERVAL 7000
\r
42 * * Define Generic String Size, to hold Error or Information
\r
44 #define MAX_STR_SIZE 1024
\r
47 * Delcare Global variables, which are visible to other modules
49 extern BOOL g_fRunningAsService;
52 * Input parameter structure to thread
54 typedef struct _InputParams
\r {
61 * * Define Service Related functions
\r
65 * To register application as windows service with SCM
82 VOID RegisterService(LPCTSTR lpszServiceName,
83 LPCTSTR lpszServiceDisplayName,
84 LPCTSTR lpszServiceDescription,
85 InputParams * StartUpArg);
88 * To unregister servcie
90 VOID UnregisterService(LPCSTR lpszServiceName);
93 * To parse command line for startup option
102 INT ParseCmdLineForServiceOption(INT argc, TCHAR * argv[]);
105 * To write to windows event log
112 VOID WriteToEventLog(WORD wType, LPCTSTR pszFormat, ...);
115 * To display generic windows error
117 VOID DisplayError(LPCTSTR pszTitle);
120 * To update windows service status to SCM
122 static BOOL UpdateServiceStatus(DWORD dwStatus, DWORD dwErrorCode,
126 * To Report current service status to SCM
128 static BOOL ReportCurrentServiceStatus();
131 * Service Main function, Which will spawn a thread, and calls the
\r
132 * * Service run part
\r
134 VOID WINAPI ServiceMain(DWORD argc, LPTSTR argv[]);
144 BOOL RunAsService(INT(*ServiceFunction) (INT, LPTSTR *));
147 * Call back function to process SCM Requests
149 VOID WINAPI ControlHandler(DWORD dwControl);
152 * To Stop the service
154 VOID ProcessServiceStop(VOID);
159 VOID ProcessServicePause(VOID);
162 * To Continue paused service
164 VOID ProcessServiceContinue(VOID);
167 * To send Current Serivce status to SCM when INTERROGATE command is sent
169 VOID ProcessServiceInterrogate(VOID);
172 * To allocate and Set security descriptor
189 BOOL SetSimpleSecurityAttributes(SECURITY_ATTRIBUTES *
193 * To free Securtiy Descriptor
208 VOID FreeSecurityAttributes(SECURITY_ATTRIBUTES * pSecurityAttr);
211 * TheadFunction - To spawan as thread - Invokes registered service function
213 DWORD WINAPI ThreadFunction(LPVOID lpParam);
216 * Service STOP function registration with this framewrok
\r
217 * * this function must be invoked before calling RunAsService
\r
219 VOID RegisterStopFunction(VOID(*StopFunc) ());
224 #endif /* WINSERVICE_H */
\r