Leaked source code of windows server 2003
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.

214 lines
5.8 KiB

  1. #ifndef _MDKEY_H_
  2. #define _MDKEY_H_
  3. class CMDValue
  4. {
  5. protected:
  6. DWORD m_dwId;
  7. DWORD m_dwAttributes;
  8. DWORD m_dwUserType;
  9. DWORD m_dwDataType;
  10. DWORD m_cbDataLen;
  11. BUFFER m_bufData;
  12. public:
  13. CMDValue();
  14. ~CMDValue();
  15. DWORD SetValue(DWORD dwId,
  16. DWORD dwAttributes,
  17. DWORD dwUserType,
  18. DWORD dwDataType,
  19. DWORD dwDataLen,
  20. LPVOID pbData);
  21. DWORD SetValue(DWORD dwId,
  22. DWORD dwAttributes,
  23. DWORD dwUserType,
  24. DWORD dwDataType,
  25. DWORD dwDataLen,
  26. LPTSTR szDataString);
  27. DWORD SetValue(DWORD dwId,
  28. DWORD dwAttributes,
  29. DWORD dwUserType,
  30. DWORD dwValue);
  31. DWORD GetId() { return m_dwId; }
  32. DWORD GetAttributes() { return m_dwAttributes; }
  33. DWORD GetUserType() { return m_dwUserType; }
  34. DWORD GetDataType() { return m_dwDataType; }
  35. DWORD GetDataLen() { return m_cbDataLen; }
  36. PVOID GetData() { return m_bufData.QueryPtr(); }
  37. void SetAttributes(DWORD dwAttrib) { m_dwAttributes = dwAttrib; }
  38. BOOL IsEqual(DWORD dwDataType, DWORD cbDataLen, LPVOID pbData);
  39. BOOL IsEqual(DWORD dwDataType, DWORD cbDataLen, DWORD dwData);
  40. };
  41. class CMDKey : public CObject
  42. {
  43. protected:
  44. IMSAdminBase * m_pcCom;
  45. METADATA_HANDLE m_hKey;
  46. LPTSTR pszFailedAPI;
  47. public:
  48. CMDKey();
  49. ~CMDKey();
  50. TCHAR m_szCurrentNodeName[_MAX_PATH];
  51. // allow CMDKey to be used where type METADATA_HANDLE is required
  52. operator METADATA_HANDLE () {return m_hKey;}
  53. METADATA_HANDLE GetMDKeyHandle() {return m_hKey;}
  54. IMSAdminBase *GetMDKeyICOM() {return m_pcCom;}
  55. // open an existing MD key
  56. HRESULT OpenNode(LPCTSTR pchSubKeyPath, BOOL bSupressErrorMessage = FALSE);
  57. // to open an existing MD key, or create one if doesn't exist
  58. HRESULT CreateNode(METADATA_HANDLE hKeyBase, LPCTSTR pchSubKeyPath);
  59. // close node opened/created by OpenNode() or CreateNode()
  60. HRESULT Close();
  61. // Add a node
  62. HRESULT AddNode( LPWSTR szNodeName );
  63. HRESULT ForceWriteMetabaseToDisk();
  64. HRESULT DeleteNode(LPCTSTR pchSubKeyPath);
  65. BOOL IsEmpty( PWCHAR pszSubString = L"" );
  66. int GetNumberOfSubKeys( PWCHAR pszSubString = L"" );
  67. // get all the sub keys that have a certain property on them and return the
  68. // sub-paths in a cstring list object. The cstring list should be instantiated
  69. // by the caller and deleted by the same.
  70. HRESULT GetDataPaths(
  71. DWORD dwMDIdentifier,
  72. DWORD dwMDDataType,
  73. CStringList& szPathList,
  74. PWCHAR pszSubString = L"" );
  75. HRESULT GetMultiSzAsStringList (
  76. DWORD dwMDIdentifier,
  77. DWORD *uType,
  78. DWORD *attributes,
  79. CStringList& szStrList,
  80. LPCWSTR pszSubString = L"" );
  81. HRESULT SetMultiSzAsStringList (
  82. DWORD dwMDIdentifier,
  83. DWORD uType,
  84. DWORD attributes,
  85. CStringList& szStrList,
  86. PWCHAR pszSubString = L"" );
  87. HRESULT GetStringAsCString (
  88. DWORD dwMDIdentifier,
  89. DWORD uType,
  90. DWORD attributes,
  91. CString& szStrList,
  92. PWCHAR pszSubString = L"",
  93. int iStringType = 0);
  94. HRESULT SetCStringAsString (
  95. DWORD dwMDIdentifier,
  96. DWORD uType,
  97. DWORD attributes,
  98. CString& szStrList,
  99. PWCHAR pszSubString = L"",
  100. int iStringType = 0);
  101. HRESULT GetDword(
  102. DWORD dwMDIdentifier,
  103. DWORD uType,
  104. DWORD attributes,
  105. DWORD& MyDword,
  106. PWCHAR pszSubString = L"");
  107. HRESULT SetData(
  108. DWORD id,
  109. DWORD attr,
  110. DWORD uType,
  111. DWORD dType,
  112. DWORD cbLen,
  113. LPBYTE pbData,
  114. PWCHAR pszSubString = L"" );
  115. BOOL GetData(DWORD id,
  116. DWORD *pdwAttr,
  117. DWORD *pdwUType,
  118. DWORD *pdwDType,
  119. DWORD *pcbLen,
  120. LPBYTE pbData,
  121. DWORD BufSize,
  122. LPCWSTR pszSubString = L"" );
  123. BOOL GetData(DWORD id,
  124. DWORD *pdwAttr,
  125. DWORD *pdwUType,
  126. DWORD *pdwDType,
  127. DWORD *pcbLen,
  128. LPBYTE pbData,
  129. DWORD BufSize,
  130. DWORD dwAttributes,
  131. DWORD dwUType,
  132. DWORD dwDType,
  133. LPCWSTR pszSubString = L"" );
  134. BOOL EnumKeys( LPWSTR pchMDName,
  135. DWORD dwIndex,
  136. LPTSTR pszSubKeyPath = _T("") );
  137. HRESULT DeleteData(DWORD id, DWORD dType, PWCHAR pszSubString = L"" );
  138. HRESULT RenameNode(LPCTSTR pszMDPath,LPCTSTR pszMDNewName);
  139. BOOL GetData(CMDValue &Value,
  140. DWORD id,
  141. LPCWSTR pszSubString = L"" );
  142. BOOL SetData(CMDValue &Value,
  143. DWORD id,
  144. PWCHAR pszSubString = L"" );
  145. static BOOL Backup( LPWSTR szBackupName,
  146. DWORD dwVersion,
  147. DWORD dwFlags );
  148. static BOOL DeleteBackup( LPWSTR szBackupName,
  149. DWORD dwVersion = MD_BACKUP_HIGHEST_VERSION );
  150. private:
  151. HRESULT DoCoInitEx();
  152. void DoCoUnInit();
  153. static HRESULT CreateABO( IMSAdminBase **ppcABO );
  154. static void CloseABO( IMSAdminBase *pcABO );
  155. // a count of the calls to coinit
  156. INT m_cCoInits;
  157. };
  158. class CMDKeyIter : public CObject
  159. {
  160. protected:
  161. IMSAdminBase * m_pcCom;
  162. METADATA_HANDLE m_hKey;
  163. LPWSTR m_pBuffer;
  164. DWORD m_dwBuffer;
  165. public:
  166. CMDKeyIter(CMDKey &cmdKey);
  167. ~CMDKeyIter();
  168. LONG Next(CString *pcsName, PWCHAR pwcsSubString = L"");
  169. void Reset() {m_index = 0;}
  170. DWORD m_index;
  171. };
  172. #endif // _MDKEY_H_