Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

WinService.h

Go to the documentation of this file.
00001 /*                                                                           
00002  * Dibbler - a portable DHCPv6 
00003  *                                                                           
00004  * authors: Tomasz Mrugalski <thomson@klub.com.pl>                           
00005  *          Marek Senderski <msend@o2.pl>                                    
00006  *          win2k version by <sob@hisoftware.cz>
00007  *
00008  * $Id: WinService.h,v 1.2 2005/07/26 00:03:03 thomson Exp $
00009  *                                                                           
00010  * Released under GNU GPL v2 licence                                
00011  *
00012  */
00013 
00014 #ifndef _WINSERVICE_
00015 #define _WINSERVICE_
00016 
00017 #include <windows.h>
00018 #include <string>
00019 
00020 #define SERVICE_CONTROL_USER 128
00021 
00022 typedef enum {
00023         STATUS,
00024         START,
00025         STOP,
00026         INSTALL,
00027         UNINSTALL,
00028     SERVICE,
00029         RUN,
00030         HELP,
00031         INVALID
00032 } EServiceState;
00033 
00034 class TWinService
00035 {
00036 public:
00037   std::string ServiceDir;
00038   TWinService(const char* serviceName, const char* dispName,
00039               DWORD deviceType=SERVICE_DEMAND_START,
00040               char* dependencies=NULL, char* descr=NULL);
00041   static void WINAPI ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
00042   static void WINAPI Handler(DWORD dwOpcode);
00043   void LogEvent(WORD wType, DWORD dwID, const char* pszS1 = NULL,
00044                 const char* pszS2 = NULL, const char* pszS3 = NULL);
00045   bool IsInstalled();
00046   bool IsInstalled(const char *name);
00047   bool Install();
00048   bool Uninstall();
00049   bool StartService(); /* invoked to trigger start */
00050   bool RunService();   /* actual service start and run */
00051   bool StopService();
00052   void SetStatus(DWORD dwState);
00053   bool Initialize();
00054   bool verifyPort();
00055   
00056   virtual void Run();
00057   virtual bool OnInit();
00058   virtual void OnStop();
00059   virtual void OnInterrogate();
00060   virtual void OnPause();
00061   virtual void OnContinue();
00062   virtual void OnShutdown();
00063   virtual bool OnUserControl(DWORD dwOpcode);
00064   void showStatus();
00065   int getStatus();
00066   bool isRunning(const char * name);
00067   bool isRunning();
00068   ~TWinService(void);
00069   
00070  protected:
00071   SERVICE_STATUS Status;
00072   SERVICE_STATUS_HANDLE hServiceStatus;
00073   BOOL IsRunning;
00074   char ServiceName[64];
00075   int MajorVersion;
00076   int MinorVersion;
00077   DWORD ServiceType;
00078   char* Dependencies;
00079   char* DisplayName;
00080   char* descr;
00081   static TWinService* ServicePtr;
00082   HANDLE EventSource;
00083 };
00084 #endif
00085 
00086 /*
00087  * $Log: WinService.h,v $
00088  * Revision 1.2  2005/07/26 00:03:03  thomson
00089  * Preparation for relase 0.4.1
00090  *
00091  * Revision 1.1  2005/07/23 14:33:22  thomson
00092  * Port for win2k/NT added.
00093  *
00094  */
00095 

Generated on Sun Aug 7 22:47:16 2005 for Dibbler - a portable DHCPv6 by  doxygen 1.3.9.1