#ifndef _ALLSRV_MOD_
#define _ALLSRV_MOD_
#ifndef STRICT
#define STRICT
#endif
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif
#define _ATL_APARTMENT_THREADED
#include <atlbase.h>
#include <AGC.h>
#include <..\TCLib\AutoHandle.h>
class CServiceModule : public CComModule
{
public:
CServiceModule() :
m_fCOMStarted(false)
{
}
HRESULT Init(HINSTANCE hInst);
void Term();
HRESULT InitAGC();
void TermAGC();
public:
BOOL IsInstalled(); BOOL IsInstalledAsService(); BOOL IsInServiceControlManager(); HRESULT get_EventLog(IAGCEventLogger** ppEventLogger);
public:
HRESULT RegisterServer(BOOL bReRegister, BOOL bRegTypeLib, BOOL bService, int argc, char * argv[]);
HRESULT UnregisterServer();
void RegisterCOMObjects();
void RevokeCOMObjects();
VOID RunAsExecutable();
BOOL InstallService(int argc, char * argv[]);
BOOL RemoveService(void);
static void WINAPI ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
void SetCOMStarted(bool fCOMStarted) { m_fCOMStarted = fCOMStarted; }
bool WasCOMStarted() { return m_fCOMStarted; }
void StopAllsrv();
protected:
static void WINAPI StartServerTerminateThread();
static void WINAPI ServiceControl(DWORD dwCode);
static void SetSvcStatus(DWORD state, DWORD exitcode);
static DWORD WINAPI ServerTerminateThread(DWORD dwUnused);
static DWORD WINAPI MTAKeepAliveThunk(void* pvThis);
void MTAKeepAliveThread();
protected:
bool m_fCOMStarted; TCHandle m_shthMTA; TCHandle m_shevtMTAReady; TCHandle m_shevtMTAExit; HRESULT m_hrMTAKeepAlive; IAGCEventLoggerPtr m_spEventLogger;
};
extern CServiceModule _Module;
#include <atlcom.h>
void PrintSystemErrorMessage(LPCTSTR szBuf, DWORD dwErrorCode);
void WINAPI _ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
extern const GUID APPID_AllSrv;
extern const char *c_szAPPID_AllSrv; extern const CATID CATID_AllegianceAdmin;
#endif