allsrvmodule.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*-------------------------------------------------------------------------
  2. * fedsrv\AllSrvModule.H
  3. *
  4. * This part of AllSrv contains Service-related functions and COM/ATL support.
  5. *
  6. * Owner:
  7. *
  8. * Copyright 1986-1999 Microsoft Corporation, All Rights Reserved
  9. *-----------------------------------------------------------------------*/
  10. #ifndef _ALLSRV_MOD_
  11. #define _ALLSRV_MOD_
  12. #ifndef STRICT
  13. #define STRICT
  14. #endif
  15. #ifndef _WIN32_WINNT
  16. #define _WIN32_WINNT 0x0400
  17. #endif
  18. #define _ATL_APARTMENT_THREADED
  19. #include <atlbase.h>
  20. #include <AGC.h>
  21. #include <..\TCLib\AutoHandle.h>
  22. //You may derive a class from CComModule and use it if you want to override
  23. //something, but do not change the name of _Module
  24. class CServiceModule : public CComModule
  25. {
  26. // Construction / Destruction
  27. public:
  28. CServiceModule() :
  29. m_fCOMStarted(false)
  30. {
  31. }
  32. HRESULT Init(HINSTANCE hInst);
  33. void Term();
  34. HRESULT InitAGC();
  35. void TermAGC();
  36. // Attributes
  37. public:
  38. BOOL IsInstalled(); // returns TRUE iff AllSrv was properly installed (either as Service or EXE)
  39. BOOL IsInstalledAsService(); // returns TRUE iff AllSrv is installed as an NT service.
  40. BOOL IsInServiceControlManager(); // TRUE iff AllSrv is an NT service (by checking the Service Control Manager)
  41. HRESULT get_EventLog(IAGCEventLogger** ppEventLogger);
  42. // Operations
  43. public:
  44. HRESULT RegisterServer(BOOL bReRegister, BOOL bRegTypeLib, BOOL bService, int argc, char * argv[]);
  45. HRESULT UnregisterServer();
  46. void RegisterCOMObjects();
  47. void RevokeCOMObjects();
  48. VOID RunAsExecutable();
  49. BOOL InstallService(int argc, char * argv[]);
  50. BOOL RemoveService(void);
  51. static void WINAPI ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
  52. void SetCOMStarted(bool fCOMStarted) { m_fCOMStarted = fCOMStarted; }
  53. bool WasCOMStarted() { return m_fCOMStarted; }
  54. void StopAllsrv();
  55. // Implementation
  56. protected:
  57. static void WINAPI StartServerTerminateThread();
  58. static void WINAPI ServiceControl(DWORD dwCode);
  59. static void SetSvcStatus(DWORD state, DWORD exitcode);
  60. static DWORD WINAPI ServerTerminateThread(DWORD dwUnused);
  61. static DWORD WINAPI MTAKeepAliveThunk(void* pvThis);
  62. void MTAKeepAliveThread();
  63. // Data Members
  64. protected:
  65. bool m_fCOMStarted; // true if a COM call started the server
  66. // HANDLE m_hEventStopRunningAsEXE;
  67. TCHandle m_shthMTA; // thread handle of MTA keep-alive thread
  68. TCHandle m_shevtMTAReady; // event to sync MTA keep-alive thread
  69. TCHandle m_shevtMTAExit; // event to sync MTA keep-alive thread
  70. HRESULT m_hrMTAKeepAlive; // HRESULT from MTA keep-alive thread
  71. IAGCEventLoggerPtr m_spEventLogger;
  72. };
  73. extern CServiceModule _Module;
  74. #include <atlcom.h>
  75. void PrintSystemErrorMessage(LPCTSTR szBuf, DWORD dwErrorCode);
  76. void WINAPI _ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
  77. extern const GUID APPID_AllSrv;
  78. extern const char *c_szAPPID_AllSrv; // string form of APPID_AllSrv
  79. extern const CATID CATID_AllegianceAdmin;
  80. #endif //_ALLSRV_MOD