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.

193 lines
4.9 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 GetId() { return m_dwId; }
  28. DWORD GetAttributes() { return m_dwAttributes; }
  29. DWORD GetUserType() { return m_dwUserType; }
  30. DWORD GetDataType() { return m_dwDataType; }
  31. DWORD GetDataLen() { return m_cbDataLen; }
  32. PVOID GetData() { return m_bufData.QueryPtr(); }
  33. BOOL IsEqual(DWORD dwDataType, DWORD cbDataLen, LPVOID pbData);
  34. BOOL IsEqual(DWORD dwDataType, DWORD cbDataLen, DWORD dwData);
  35. };
  36. class CMDKey : public CObject
  37. {
  38. protected:
  39. IMSAdminBase * m_pcCom;
  40. METADATA_HANDLE m_hKey;
  41. LPTSTR pszFailedAPI;
  42. public:
  43. CMDKey();
  44. ~CMDKey();
  45. TCHAR m_szCurrentNodeName[_MAX_PATH];
  46. // allow CMDKey to be used where type METADATA_HANDLE is required
  47. operator METADATA_HANDLE () {return m_hKey;}
  48. METADATA_HANDLE GetMDKeyHandle() {return m_hKey;}
  49. IMSAdminBase *GetMDKeyICOM() {return m_pcCom;}
  50. // open an existing MD key
  51. HRESULT OpenNode(LPCTSTR pchSubKeyPath);
  52. // to open an existing MD key, or create one if doesn't exist
  53. HRESULT CreateNode(METADATA_HANDLE hKeyBase, LPCTSTR pchSubKeyPath);
  54. // close node opened/created by OpenNode() or CreateNode()
  55. HRESULT Close();
  56. HRESULT ForceWriteMetabaseToDisk();
  57. HRESULT DeleteNode(LPCTSTR pchSubKeyPath);
  58. BOOL IsEmpty( PWCHAR pszSubString = L"" );
  59. int GetNumberOfSubKeys( PWCHAR pszSubString = L"" );
  60. // get all the sub keys that have a certain property on them and return the
  61. // sub-paths in a cstring list object. The cstring list should be instantiated
  62. // by the caller and deleted by the same.
  63. HRESULT GetDataPaths(
  64. DWORD dwMDIdentifier,
  65. DWORD dwMDDataType,
  66. CStringList& szPathList,
  67. PWCHAR pszSubString = L"" );
  68. HRESULT GetMultiSzAsStringList (
  69. DWORD dwMDIdentifier,
  70. DWORD *uType,
  71. DWORD *attributes,
  72. CStringList& szStrList,
  73. PWCHAR pszSubString = L"" );
  74. HRESULT SetMultiSzAsStringList (
  75. DWORD dwMDIdentifier,
  76. DWORD uType,
  77. DWORD attributes,
  78. CStringList& szStrList,
  79. PWCHAR pszSubString = L"" );
  80. HRESULT GetStringAsCString (
  81. DWORD dwMDIdentifier,
  82. DWORD uType,
  83. DWORD attributes,
  84. CString& szStrList,
  85. PWCHAR pszSubString = L"",
  86. int iStringType = 0);
  87. HRESULT SetCStringAsString (
  88. DWORD dwMDIdentifier,
  89. DWORD uType,
  90. DWORD attributes,
  91. CString& szStrList,
  92. PWCHAR pszSubString = L"",
  93. int iStringType = 0);
  94. HRESULT GetDword(
  95. DWORD dwMDIdentifier,
  96. DWORD uType,
  97. DWORD attributes,
  98. DWORD& MyDword,
  99. PWCHAR pszSubString = L"");
  100. HRESULT SetData(
  101. DWORD id,
  102. DWORD attr,
  103. DWORD uType,
  104. DWORD dType,
  105. DWORD cbLen,
  106. LPBYTE pbData,
  107. PWCHAR pszSubString = L"" );
  108. BOOL GetData(DWORD id,
  109. DWORD *pdwAttr,
  110. DWORD *pdwUType,
  111. DWORD *pdwDType,
  112. DWORD *pcbLen,
  113. LPBYTE pbData,
  114. DWORD BufSize,
  115. PWCHAR pszSubString = L"" );
  116. BOOL GetData(DWORD id,
  117. DWORD *pdwAttr,
  118. DWORD *pdwUType,
  119. DWORD *pdwDType,
  120. DWORD *pcbLen,
  121. LPBYTE pbData,
  122. DWORD BufSize,
  123. DWORD dwAttributes,
  124. DWORD dwUType,
  125. DWORD dwDType,
  126. PWCHAR pszSubString = L"" );
  127. HRESULT DeleteData(DWORD id, DWORD dType, PWCHAR pszSubString = L"" );
  128. HRESULT RenameNode(LPCTSTR pszMDPath,LPCTSTR pszMDNewName);
  129. BOOL GetData(CMDValue &Value,
  130. DWORD id,
  131. PWCHAR pszSubString = L"" );
  132. BOOL SetData(CMDValue &Value,
  133. DWORD id,
  134. PWCHAR pszSubString = L"" );
  135. private:
  136. HRESULT DoCoInitEx();
  137. void DoCoUnInit();
  138. // a count of the calls to coinit
  139. INT m_cCoInits;
  140. };
  141. class CMDKeyIter : public CObject
  142. {
  143. protected:
  144. IMSAdminBase * m_pcCom;
  145. METADATA_HANDLE m_hKey;
  146. LPWSTR m_pBuffer;
  147. DWORD m_dwBuffer;
  148. public:
  149. CMDKeyIter(CMDKey &cmdKey);
  150. ~CMDKeyIter();
  151. LONG Next(CString *pcsName, PWCHAR pwcsSubString = L"");
  152. void Reset() {m_index = 0;}
  153. DWORD m_index;
  154. };
  155. #endif // _MDKEY_H_