Service.h

Go to the documentation of this file.
00001 
00010 /* $Id: Service.h 629 2004-02-21 23:01:47Z harald $ */
00011 
00012 #pragma once
00013 
00014 #define WINDOWS_LEAN_AND_MEAN
00015 #include <windows.h>
00016 #include <string>
00017 
00018 #include "messages.h"
00019 
00020 #define SERVICE_CONTROL_USER 180
00021 
00022 using namespace std;
00023 
00024 class Service
00025 {
00026 public:
00027     virtual ~Service();
00028 
00029         bool parseStandardArgs(int argc, char* argv[]);
00030     bool startService();
00031         int exitService();
00032 
00033         string ToString();
00034 
00035 protected:
00036         Service(LPTSTR name, LPTSTR desc);
00037 
00038         void setStatus(DWORD dwState);
00039     void logEvent(WORD wType, DWORD dwID,
00040                   const char* pszS1 = NULL,
00041                   const char* pszS2 = NULL,
00042                   const char* pszS3 = NULL);
00043 
00044     bool isInstalled();
00045     bool install();
00046     bool uninstall();
00047     bool initialize();
00048 
00049         virtual void run();
00050         virtual bool onInstall();
00051         virtual bool onUninstall();
00052         virtual bool onInit();
00053     virtual void onStop();
00054     virtual void onInterrogate();
00055     virtual void onPause();
00056     virtual void onContinue();
00057     virtual void onShutdown();
00058     virtual bool onUserControl(DWORD dwOpcode);
00059 
00060         virtual void printVersion() {};
00061         virtual void execConsole(int l) { run(); }
00062     
00063         static void DebugMsg(const char* pszFormat, ...);
00064     
00065     bool isRunning;
00066 
00067         // static data
00068     static Service *This;
00069 
00070 private:
00071         void printHelp();
00072 
00073     // data members
00074     LPTSTR ServiceName;
00075     LPTSTR ServiceDesc;
00076     SERVICE_STATUS_HANDLE ServiceStatus;
00077     SERVICE_STATUS Status;
00078 
00079     HANDLE EventSource;
00080 
00081     // static member functions
00082     static void WINAPI ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
00083         static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType);
00084     static void WINAPI Handler(DWORD dwOpcode);
00085 };

Generated on Mon Jun 5 10:20:43 2006 for Intelligence.kdevelop by  doxygen 1.4.6