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.

129 lines
1.7 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. enum.cxx
  5. Abstract:
  6. General metadata utility functions.
  7. Author:
  8. Keith Moore (keithmo) 05-Feb-1997
  9. Revision History:
  10. --*/
  11. #include "precomp.hxx"
  12. #pragma hdrstop
  13. //
  14. // Private constants.
  15. //
  16. //
  17. // Private types.
  18. //
  19. //
  20. // Private globals.
  21. //
  22. //
  23. // Private prototypes.
  24. //
  25. //
  26. // Public functions.
  27. //
  28. HRESULT
  29. MdEnumMetaObjects(
  30. IN IMSAdminBase * AdmCom,
  31. IN LPWSTR KeyName,
  32. IN PFN_ADMIN_ENUM_CALLBACK Callback,
  33. IN VOID * Context
  34. )
  35. {
  36. HRESULT result;
  37. METADATA_HANDLE handle;
  38. DWORD index;
  39. WCHAR path[MAX_PATH];
  40. //
  41. // Setup locals so we know how to cleanup on exit.
  42. //
  43. handle = 0;
  44. //
  45. // Open the metabase.
  46. //
  47. result = AdmCom->OpenKey(
  48. METADATA_MASTER_ROOT_HANDLE,
  49. KeyName,
  50. METADATA_PERMISSION_READ,
  51. METABASE_OPEN_TIMEOUT,
  52. &handle
  53. );
  54. if( FAILED(result) ) {
  55. goto Cleanup;
  56. }
  57. //
  58. // Enumerate the objects.
  59. //
  60. for( index = 0 ; ; index++ ) {
  61. result = AdmCom->EnumKeys(
  62. handle,
  63. L"",
  64. path,
  65. index
  66. );
  67. if( FAILED(result) ) {
  68. break;
  69. }
  70. if( !(Callback)(
  71. AdmCom,
  72. path,
  73. Context
  74. ) ) {
  75. break;
  76. }
  77. }
  78. result = NO_ERROR;
  79. Cleanup:
  80. if( handle != 0 ) {
  81. (VOID)AdmCom->CloseKey( handle );
  82. }
  83. return result;
  84. } // MdEnumMetaObjects
  85. //
  86. // Private functions.
  87. //