Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.7 KiB

  1. #ifndef _WSBFIRST_H
  2. #define _WSBFIRST_H
  3. /*++
  4. Copyright (c) 1996 Microsoft Corporation
  5. 1998 Seagate Software, Inc. All rights reserved.
  6. Module Name:
  7. wsbfirst.h
  8. Abstract:
  9. This module defines some absolutely necessary stuff for WSB and other modules. This header is expected
  10. to be the first one included by Wsb.h
  11. Author:
  12. Michael Lotz [lotz] 12-Apr-1997
  13. Revision History:
  14. --*/
  15. //
  16. // Override values in \nt\public\inc\warning.h and other gotcha's
  17. //
  18. #pragma warning(3:4101) // Unreferenced local variable
  19. #pragma warning(3:4100) // Unreferenced formal parameter
  20. #pragma warning(3:4701) // local may be used w/o init
  21. #pragma warning(3:4702) // Unreachable code
  22. #pragma warning(3:4705) // Statement has no effect
  23. #pragma warning(3:4706) // assignment w/i conditional expression
  24. #pragma warning(3:4709) // command operator w/o index expression
  25. #pragma warning(3:4244) // 'int' conversion warnings
  26. // Demote warnings about: The string for a title or subtitle pragma exceeded the
  27. // maximum allowable length and was truncated. These show up when generating
  28. // browser info for ATL code.
  29. #pragma warning(4:4786) // command operator w/o index expression
  30. // This supresses warning messages that come from exporting
  31. // abstract classes derived from CComObjectRoot and that use
  32. // COM templates.
  33. #pragma warning(disable:4251 4275)
  34. #include <atlbase.h>
  35. //
  36. // If you are building a service, make sure your precompiled header defines WSB_ATL_COM_SERVICE. Then _Module
  37. // will be defined correctly for a service. Otherwise it we default to _Module being set correctly for a
  38. // standard module.
  39. //
  40. #ifdef WSB_ATL_COM_SERVICE
  41. // You may derive a class from CComModule and use it if you want to override
  42. // something, but do not change the name of _Module
  43. //
  44. class CServiceModule : public CComModule
  45. {
  46. public:
  47. HRESULT RegisterServer(BOOL bRegTypeLib);
  48. HRESULT UnregisterServer();
  49. void Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h);
  50. void Start();
  51. void ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
  52. DWORD HandlerEx(DWORD dwOpcode, DWORD fdwEventType,
  53. LPVOID lpEventData, LPVOID lpContext);
  54. void Run();
  55. BOOL IsInstalled();
  56. BOOL Install();
  57. BOOL Uninstall();
  58. LONG Unlock();
  59. void LogEvent(DWORD eventId, ...);
  60. void SetServiceStatus(DWORD dwState);
  61. //Implementation
  62. private:
  63. static void WINAPI _ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
  64. static DWORD WINAPI _HandlerEx(DWORD dwOpcode, DWORD fdwEventType,
  65. LPVOID lpEventData, LPVOID lpContext);
  66. // data members
  67. public:
  68. TCHAR m_szServiceName[256];
  69. SERVICE_STATUS_HANDLE m_hServiceStatus;
  70. SERVICE_STATUS m_status;
  71. DWORD dwThreadID;
  72. BOOL m_bService;
  73. };
  74. extern CServiceModule _Module;
  75. #else
  76. //
  77. //You may derive a class from CComModule and use it if you want to override
  78. //something, but do not change the name of _Module
  79. //
  80. extern CComModule _Module;
  81. #endif
  82. //
  83. // Include the basic AtlCom.h file for the rest of the COM definitions
  84. //
  85. #include <atlcom.h>
  86. // Are we defining imports or exports?
  87. #ifdef WSB_IMPL
  88. #define WSB_EXPORT __declspec(dllexport)
  89. #else
  90. #define WSB_EXPORT __declspec(dllimport)
  91. #endif
  92. // Flag values used in HSM_SYSTEM_STATE structure
  93. #define HSM_STATE_NONE 0x00000000
  94. #define HSM_STATE_SHUTDOWN 0x00000001
  95. #define HSM_STATE_SUSPEND 0x00000002
  96. #define HSM_STATE_RESUME 0x00000004
  97. // Defines for memory alloc/realloc/free functions so we can track
  98. // memory usage
  99. #if defined(WSB_TRACK_MEMORY)
  100. #define WsbAlloc(_cb) WsbMemAlloc(_cb, __FILE__, __LINE__)
  101. #define WsbFree(_pv) WsbMemFree(_pv, __FILE__, __LINE__)
  102. #define WsbRealloc(_pv, _cb) WsbMemRealloc(_pv, _cb, __FILE__, __LINE__)
  103. #define WsbAllocString(_sz) WsbSysAllocString(_sz, __FILE__, __LINE__)
  104. #define WsbAllocStringLen(_sz, _cc) WsbSysAllocStringLen(_sz, _cc, __FILE__, __LINE__)
  105. #define WsbFreeString(_bs) WsbSysFreeString(_bs, __FILE__, __LINE__)
  106. #define WsbReallocString(_pb, _sz) WsbSysReallocString(_pb, _sz, __FILE__, __LINE__)
  107. #define WsbReallocStringLen(_pb, _sz, _cc) WsbSysReallocStringLen(_pb, _sz, _cc, __FILE__, __LINE__)
  108. #else
  109. #define WsbAlloc(_cb) CoTaskMemAlloc(_cb)
  110. #define WsbFree(_pv) CoTaskMemFree(_pv)
  111. #define WsbRealloc(_pv, _cb) CoTaskMemRealloc(_pv, _cb)
  112. #define WsbAllocString(_sz) SysAllocString(_sz)
  113. #define WsbAllocStringLen(_sz, _cc) SysAllocStringLen(_sz, _cc)
  114. #define WsbFreeString(_bs) SysFreeString(_bs)
  115. #define WsbReallocString(_pb, _sz) SysReAllocString(_pb, _sz)
  116. #define WsbReallocStringLen(_pb, _sz, _cc) SysReAllocStringLen(_pb, _sz, _cc)
  117. #endif
  118. #endif // _WSBFIRST_H