• Main Page
  • Classes
  • Files
  • File List
  • File Members

Beesnest/Windows/DcDemon.h

Go to the documentation of this file.
00001 /*
00002 Copyright 2007 Erez Bibi (erezbibi@users.sourceforge.net)
00003 This file is part of Beesnest.
00004 
00005 Beesnest is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 Beesnest is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with Beesnest; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 */
00019 
00020 /* DcFileUtil.h: interface for the CdcFileUtil class. */
00021 
00022 /**
00023  * This static class make the necessary operations to run the application as a
00024  * demon (or Windows service).
00025  *
00026  * <p>
00027  * @author Erez Bibi
00028  * @version 1.0
00029  */
00030 
00031 #ifndef __CDC_DEMON
00032 #define __CDC_DEMON
00033 
00034 #include "../DcGlobals.h"
00035 
00036 class CdcDemon
00037 {
00038 private:
00039     /** Service global parameters. */
00040     static SERVICE_STATUS          ServiceStatus;
00041     static SERVICE_STATUS_HANDLE   hStatus;
00042     /** The service name (const string in fact). */
00043     static char* gsServiceName;
00044 
00045 public:
00046     /**
00047      * Install whatever it need to so it can run as demon.
00048      * This function is been called when "beesnest install" is called.
00049      */
00050     static void Install ();
00051 
00052     /**
00053      * Uninstall the demon/service from OS.
00054      * This function is been called when "beesnest uninstall" is called.
00055      */
00056     static void Uninstall ();
00057 
00058     /**
00059      * Start the demon/service in a pending state. This function is been called
00060      * by Main.cpp before Start is called.
00061      */
00062     static bool StartPending ();
00063 
00064     /**
00065      * Mark the demon/service as running.
00066      */
00067     static bool MarkRun ();
00068 
00069     /**
00070      * Stop the run of the demon/service.
00071      */
00072     static bool Stop (int code);
00073 
00074     /**
00075      * Call the ProgramMain function to run as a demon/service.
00076      * This function is been called when beesnest is called w/o any arguments.
00077      */
00078     static void RunMain ();
00079 
00080     /**
00081      * Returns True if the demon/service is running.
00082      */
00083     static bool IsRunning ()
00084     { ServiceStatus.dwCurrentState == SERVICE_RUNNING; }
00085 };
00086 
00087 #endif /* _CDC_DEMON */
00088 

Generated on Mon Oct 11 2010 16:23:25 for Beesnest by  doxygen 1.7.2