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.

263 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. mdlib.hxx
  5. Abstract:
  6. This module contains global definitions and declarations for MDLIB.
  7. Author:
  8. Keith Moore (keithmo) 05-Feb-1997
  9. Revision History:
  10. --*/
  11. #ifndef _MDLIB_HXX_
  12. #define _MDLIB_HXX_
  13. //
  14. // Initialize a metabase record.
  15. //
  16. #define INITIALIZE_METADATA_RECORD(p,id,attr,utype,dtype,dlen,ptr) \
  17. if( TRUE ) { \
  18. (p)->dwMDIdentifier = (DWORD)(id); \
  19. (p)->dwMDAttributes = (DWORD)(attr); \
  20. (p)->dwMDUserType = (DWORD)(utype); \
  21. (p)->dwMDDataType = (DWORD)(dtype); \
  22. (p)->dwMDDataLen = (DWORD)(dlen); \
  23. (p)->pbMDData = (unsigned char *)(ptr); \
  24. } else
  25. //
  26. // "Safe" interface release.
  27. //
  28. #define RELEASE_INTERFACE(p) \
  29. if( (p) != NULL ) { \
  30. (p)->Release(); \
  31. (p) = NULL; \
  32. } else
  33. //
  34. // Timeout value for metabase open requests.
  35. //
  36. #define METABASE_OPEN_TIMEOUT 10000 // milliseconds
  37. //
  38. // Get the data pointer from a METADATA_GETALL_RECORD.
  39. //
  40. #define GETALL_POINTER(base,rec) \
  41. (PVOID)( (PBYTE)(base) + (rec)->dwMDDataOffset )
  42. //
  43. // Heap.
  44. //
  45. #define MdAllocMem(cb) (LPVOID)LocalAlloc( LPTR, (cb) )
  46. #define MdFreeMem(ptr) (VOID)LocalFree( (HLOCAL)(ptr) )
  47. //
  48. // Callback for admin object enumerator.
  49. //
  50. typedef
  51. BOOL
  52. (WINAPI * PFN_ADMIN_ENUM_CALLBACK)(
  53. IMSAdminBase * AdmCom,
  54. LPWSTR ObjectName,
  55. VOID * Context
  56. );
  57. //
  58. // Base admin notification sink.
  59. //
  60. class BASE_ADMIN_SINK : public IMSAdminBaseSink {
  61. public:
  62. //
  63. // Usual constructor/destructor stuff.
  64. //
  65. BASE_ADMIN_SINK();
  66. ~BASE_ADMIN_SINK();
  67. //
  68. // Secondary constructor.
  69. //
  70. HRESULT
  71. Initialize(
  72. IN IUnknown * Object
  73. );
  74. //
  75. // Unadvise if necessary.
  76. //
  77. HRESULT
  78. Unadvise(
  79. VOID
  80. );
  81. //
  82. // IUnknown methods.
  83. //
  84. virtual
  85. HRESULT
  86. STDMETHODCALLTYPE
  87. QueryInterface(
  88. IN REFIID InterfaceId,
  89. OUT VOID ** Object
  90. );
  91. virtual
  92. ULONG
  93. STDMETHODCALLTYPE
  94. AddRef();
  95. virtual
  96. ULONG
  97. STDMETHODCALLTYPE
  98. Release();
  99. //
  100. // Change notification callback. Note that this is a pure virtual and
  101. // must be defined by a derived class.
  102. //
  103. virtual
  104. HRESULT
  105. STDMETHODCALLTYPE
  106. SinkNotify(
  107. IN DWORD NumElements,
  108. IN MD_CHANGE_OBJECT ChangeList[]
  109. ) = 0;
  110. virtual
  111. HRESULT
  112. STDMETHODCALLTYPE
  113. ShutdownNotify( void) = 0;
  114. private:
  115. //
  116. // Object reference count.
  117. //
  118. LONG m_ReferenceCount;
  119. //
  120. // The sink cookie for this sink. This is required to "unadvise" the
  121. // sink.
  122. //
  123. DWORD m_SinkCookie;
  124. //
  125. // The connection point used for this sink. This is also required to
  126. // "unadvise" this sink.
  127. //
  128. IConnectionPoint * m_ConnectionPoint;
  129. }; // BASE_ADMIN_SINK;
  130. //
  131. // MD utility functions.
  132. //
  133. HRESULT
  134. MdGetAdminObject(
  135. OUT IMSAdminBase ** AdmCom
  136. );
  137. HRESULT
  138. MdReleaseAdminObject(
  139. IN IMSAdminBase * AdmCom
  140. );
  141. HRESULT
  142. MdEnumMetaObjects(
  143. IN IMSAdminBase * AdmCom,
  144. IN LPWSTR KeyName,
  145. IN PFN_ADMIN_ENUM_CALLBACK Callback,
  146. IN VOID * Context
  147. );
  148. HRESULT
  149. MdGetAllMetaData(
  150. IN IMSAdminBase * AdmCom,
  151. IN METADATA_HANDLE Handle,
  152. IN LPWSTR Path,
  153. IN DWORD Attributes,
  154. OUT METADATA_GETALL_RECORD ** Data,
  155. OUT DWORD * NumEntries
  156. );
  157. HRESULT
  158. MdFreeMetaDataBuffer(
  159. IN VOID * Data
  160. );
  161. HRESULT
  162. MdGetInstanceState(
  163. IN IMSAdminBase * AdmCom,
  164. IN LPWSTR InstanceName,
  165. OUT DWORD * CurrentState,
  166. OUT DWORD * CurrentWin32Status
  167. );
  168. HRESULT
  169. MdControlInstance(
  170. IN IMSAdminBase * AdmCom,
  171. IN LPWSTR InstanceName,
  172. IN DWORD Command
  173. );
  174. HRESULT
  175. MdDisplayInstanceState(
  176. IN IMSAdminBase * AdmCom,
  177. IN LPWSTR InstanceName
  178. );
  179. LPWSTR
  180. MdInstanceStateToString(
  181. IN DWORD State
  182. );
  183. extern "C" {
  184. INT
  185. __cdecl
  186. wmain(
  187. INT argc,
  188. LPWSTR argv[]
  189. );
  190. } // extern "C"
  191. #endif // _MDLIB_HXX_