src/Common/Service/ServiceInstance.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #define SERVICE_CONTROL_START 0
00004 
00005 namespace AppSecInc 
00006 {
00007     namespace Service 
00008     {
00010         class ServiceInstance
00011         {
00012         private:
00013             SC_HANDLE m_h;
00014         public:
00015             ServiceInstance();
00016             virtual ~ServiceInstance();
00018             void Open(const ServiceManager& scm, const std::wstring& name, DWORD access = SERVICE_ALL_ACCESS);
00020                         void Create(const ServiceManager& scm, const ServiceCreateInfo& info);
00022                         void Delete();
00024             void Close();
00026             bool IsOpen() const { return m_h != NULL; }
00028             SC_HANDLE GetHandle() const { return m_h; }
00030             void GetServiceProcessStatus(LPSERVICE_STATUS_PROCESS) const;
00032             void Control(DWORD control);
00034             void Stop();
00036             void Start();
00038             void Restart();
00040             void Pause();
00042             void Continue();
00044             DWORD GetServiceState() const;
00046             bool IsStarted() const { return (GetServiceState() == SERVICE_RUNNING); }
00048             bool IsStopped() const { return (GetServiceState() == SERVICE_STOPPED); }
00050             bool IsPaused() const { return (GetServiceState() == SERVICE_PAUSED); }
00052             // \param sleep number of milliseconds to sleep between checks
00053             // \param timeout timeout to wait
00054             // \return true if operation successful, false on timeout
00055             bool Wait(DWORD timeout = INFINITE) const;
00057                         ServiceConfig GetConfig() const;
00059                         std::wstring GetDescription() const;
00060         };
00061     }
00062 }
00063 


© Application Security Inc. - All Rights Reserved http://msiext.codeplex.com