home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
pserv.cpl
/
pserv-2.4.exe
/
source
/
cservice.h
< prev
next >
Wrap
C/C++ Source or Header
|
2005-01-05
|
5KB
|
144 lines
#ifndef CService_H
#define CService_H
#include "afxcoll.h"
class CServiceList;
#define CHANGED_START_TYPE (1UL << 0)
#define CHANGED_DESCRIPTION (1UL << 1)
#define CHANGED_DISPLAYNAME (1UL << 2)
#define CHANGED_BINARYPATH (1UL << 3)
#define CHANGED_ERROR_CONTROL (1UL << 4)
#define CHANGED_LOGON_SYSTEM (1UL << 5)
#define CHANGED_LOGON_USER (1UL << 6)
#define CHANGED_ALLOW_UI (1UL << 7)
typedef enum
{
SERVICE_STATE_PENDING,
SERVICE_STATE_REACHED,
SERVICE_STATE_FAILED
} SERVICE_STATE_TYPE;
#include "CListViewTools.h"
class CService : public CListViewEntry
{
public:
CService(CServiceList* owner);
virtual ~CService();
virtual CString GetDisplayString(DWORD dwIndex);
virtual COLORREF GetTextColor();
virtual CString GetInfoTip();
BOOL CreateFrom(SC_HANDLE hSCM, LPENUM_SERVICE_STATUS_PROCESS lpStatus);
BOOL ApplyChanges();
BOOL Install();
BOOL Enable();
BOOL Disable();
BOOL StartAutomatically();
BOOL StartAtBoot();
BOOL StartAtSystem();
BOOL Delete();
DWORD GetProcessID()
{
return m_ServiceStatus.dwProcessId;
}
BOOL IsRunning()
{
return (m_ServiceStatus.dwCurrentState == SERVICE_RUNNING);
}
BOOL IsDisabled()
{
return (m_dwStartType == SERVICE_DISABLED);
}
SERVICE_STATE_TYPE BeginStart(LPDWORD lpdwWaitHint);
SERVICE_STATE_TYPE BeginStop(LPDWORD lpdwWaitHint);
SERVICE_STATE_TYPE BeginPause(LPDWORD lpdwWaitHint);
SERVICE_STATE_TYPE BeginContinue(LPDWORD lpdwWaitHint);
SERVICE_STATE_TYPE BeginRestart(LPDWORD lpdwWaitHint);
SERVICE_STATE_TYPE IsStarted();
SERVICE_STATE_TYPE IsRestarted();
SERVICE_STATE_TYPE IsStopped();
SERVICE_STATE_TYPE IsPaused();
SERVICE_STATE_TYPE IsContinued();
void FinishStateType();
CString GetStatusAsString();
CString GetPrintStatusAsString();
CString GetStartAsString();
static CString GetStartAsString(DWORD dwAction);
CString GetTypeAsString();
CString GetPidAsString();
CString m_strServiceName;
CString m_strDisplayName;
CString m_strBinaryPathName;
CString m_strDescription;
CString m_strServiceStartName;
CString m_strServiceStartPassword;
CString m_strLoadOrderGroup;
DWORD m_dwServiceType;
DWORD m_dwStartType;
DWORD m_dwChangeFlags;
DWORD m_dwErrorControl;
SERVICE_STATUS_PROCESS m_ServiceStatus;
CServiceList* GetOwner()
{
return m_pOwner;
}
protected:
BOOL RefreshServiceStatus();
SC_HANDLE m_hTempService;
SC_HANDLE m_hTempSCM;
CServiceList* m_pOwner;
BOOL m_bRestartPending;
BOOL m_bRestartHasBeenStopped;
};
typedef SERVICE_STATE_TYPE (CService::*BEGINSTATFN)(LPDWORD lpdwWaitHint);
typedef SERVICE_STATE_TYPE (CService::*QUERYSTATEFN)();
typedef BOOL (CService::*SETSTARTTYPEFN)();
class CServiceList : public CListViewEntries
{
public:
CServiceList();
~CServiceList();
BOOL Refresh();
virtual void ExportXmlToFile( CFile* pFile );
void SetEnumType( DWORD dwEnumType );
void ConnectTo( LPCTSTR lpszMachine );
LPCTSTR GetTagString()
{
return (m_dwEnumType == SERVICE_WIN32) ? TEXT("services") : TEXT("devices");
}
virtual UINT GetContextMenuID();
static int SortByDisplayName(const CService** ps1, const CService** ps2);
static int SortByServiceName(const CService** ps1, const CService** ps2);
static int SortByStatus(const CService** ps1, const CService** ps2);
static int SortByStart(const CService** ps1, const CService** ps2);
static int SortByType(const CService** ps1, const CService** ps2);
static int SortByBinaryPathName(const CService** ps1, const CService** ps2);
static int SortByUser(const CService** ps1, const CService** ps2);
static int SortByLoadOrderGroup(const CService** ps1, const CService** ps2);
static int SortByPid(const CService** ps1, const CService** ps2);
static int SortByDescription(const CService** ps1, const CService** ps2);
DWORD m_dwEnumType;
CStringArray m_LoadOrderGroups;
BOOL AddServiceFromStatus(SC_HANDLE hSCM, LPENUM_SERVICE_STATUS_PROCESS lpStatus);
private:
void RefreshTitleString();
};
#endif // CService_H