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.

111 lines
3.6 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 GetMultiSZString( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, LPTSTR pszValue, DWORD cchValue,
  52. DWORD dwFlags = METADATA_INHERIT );
  53. BOOL GetData( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, DWORD dwDataType,
  54. PVOID pData, DWORD* pcbData, DWORD dwFlags = METADATA_INHERIT );
  55. PVOID GetData( LPCTSTR pszPath, DWORD dwPropID, DWORD dwUserType, DWORD dwDataType,
  56. DWORD* pcbData, DWORD dwFlags = METADATA_INHERIT );
  57. // deleting values
  58. BOOL DeleteData( LPCTSTR pszPath, DWORD dwPropID, DWORD dwDataType );
  59. // free memory returned by GetData
  60. void FreeWrapData( PVOID pData );
  61. protected:
  62. // pointer to the real metabase object as defined in mb.hxx
  63. // by casting it PVOID, those files including this will not have to include mb.hxx, which
  64. // is the whole point of wrapping it like this.
  65. // PVOID m_pvMB;
  66. // pointer to the dcom interface it should use
  67. IMSAdminBase * m_pMetabase;
  68. // the open metabase handle
  69. METADATA_HANDLE m_hMeta;
  70. // size of the local buffer
  71. #define BUFFER_SIZE 2000
  72. // local buffer - allocated once, used many times
  73. PVOID m_pBuffer;
  74. DWORD m_cbBuffer;
  75. // path conversion utilities
  76. WCHAR * PrepPath( LPCTSTR psz );
  77. void UnprepPath();
  78. WCHAR * m_pPathBuffer;
  79. DWORD m_cchPathBuffer;
  80. };
  81. #endif //_WRAPMB_