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.

109 lines
3.4 KiB

  1. #ifndef _WRAPMB_
  2. #define _WRAPMB_
  3. /*++
  4. Notes: I made some changes to this library to build both a UNICODE and ANSI version
  5. RonaldM
  6. --*/
  7. #include "iadmw.h"
  8. //--------------------------------------------------------
  9. // startup & closeing utilities
  10. BOOL FInitMetabaseWrapper( OLECHAR* pocMachineName );
  11. BOOL FCloseMetabaseWrapper();
  12. //
  13. // As above, privately maintaining the interface
  14. //
  15. BOOL FInitMetabaseWrapperEx( OLECHAR* pocMachineName, IMSAdminBase ** ppiab );
  16. BOOL FCloseMetabaseWrapperEx(IMSAdminBase ** ppiab);
  17. //--------------------------------------------------------
  18. class CWrapMetaBase
  19. {
  20. public:
  21. WORD m_count;
  22. // construct - destruct
  23. CWrapMetaBase();
  24. ~CWrapMetaBase();
  25. // second stage initialization
  26. BOOL FInit( PVOID pMBCom = NULL);
  27. // open, close and save the object and such
  28. BOOL Open( LPCTSTR pszPath, DWORD dwFlags = METADATA_PERMISSION_READ );
  29. BOOL Open( METADATA_HANDLE hOpenRoot, LPCTSTR pszPath,
  30. DWORD dwFlags = METADATA_PERMISSION_READ );
  31. BOOL Close( void );
  32. BOOL Save( void );
  33. // enumerate the objects
  34. BOOL EnumObjects( LPCTSTR pszPath, LPTSTR Name, DWORD cbNameBuf, DWORD Index );
  35. // Add and delete objects
  36. BOOL AddObject( LPCTSTR pszPath );
  37. BOOL DeleteObject( LPCTSTR pszPath );
  38. // rename an object
  39. BOOL RenameObject( LPCTSTR pszPathOld, LPCTSTR pszNewName );
  40. // access the metahandle
  41. METADATA_HANDLE QueryHandle();
  42. // setting values
  43. BOOL SetDword( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, DWORD dwValue, DWORD dwFlags = METADATA_INHERIT );
  44. BOOL SetString( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, LPCTSTR dwValue, DWORD dwFlags = METADATA_INHERIT );
  45. BOOL SetData( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, DWORD dwDataType,
  46. PVOID pData, DWORD cbData, DWORD dwFlags = METADATA_INHERIT );
  47. // getting values
  48. BOOL GetDword( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, DWORD* dwValue, DWORD dwFlags = METADATA_INHERIT );
  49. BOOL GetString( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, LPTSTR pszValue, DWORD cchValue,
  50. DWORD dwFlags = METADATA_INHERIT );
  51. BOOL GetData( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, DWORD dwDataType,
  52. PVOID pData, DWORD* pcbData, DWORD dwFlags = METADATA_INHERIT );
  53. PVOID GetData( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, DWORD dwDataType,
  54. DWORD* pcbData, DWORD dwFlags = METADATA_INHERIT );
  55. // deleting values
  56. BOOL DeleteData( LPCTSTR pszPath, DWORD dwPropID, DWORD dwDataType );
  57. // free memory returned by GetData
  58. void FreeWrapData( PVOID pData );
  59. protected:
  60. // pointer to the real metabase object as defined in mb.hxx
  61. // by casting it PVOID, those files including this will not have to include mb.hxx, which
  62. // is the whole point of wrapping it like this.
  63. // PVOID m_pvMB;
  64. // pointer to the dcom interface it should use
  65. IMSAdminBase * m_pMetabase;
  66. // the open metabase handle
  67. METADATA_HANDLE m_hMeta;
  68. // size of the local buffer
  69. #define BUFFER_SIZE 2000
  70. // local buffer - allocated once, used many times
  71. PVOID m_pBuffer;
  72. DWORD m_cbBuffer;
  73. // path conversion utilities
  74. WCHAR * PrepPath( LPCTSTR psz );
  75. void UnprepPath();
  76. WCHAR * m_pPathBuffer;
  77. DWORD m_cchPathBuffer;
  78. };
  79. #endif //_WRAPMB_