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.

195 lines
3.6 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996
  5. //
  6. // File: dump.cxx
  7. //
  8. // Contents: Reads the schema for objects and dumps them
  9. //
  10. // History: 07-09-96 ramv created
  11. // 08-05-96 t-danal add to oledscmd
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "main.hxx"
  15. #include "macro.hxx"
  16. #include "sconv.hxx"
  17. #include "proputil.hxx"
  18. //
  19. // Local functions
  20. //
  21. HRESULT
  22. ListProperties(
  23. LPWSTR szADsPath
  24. );
  25. HRESULT
  26. DumpObject(
  27. IADs * pADs
  28. );
  29. //
  30. // Local function definitions
  31. //
  32. HRESULT
  33. ListProperties(
  34. LPWSTR szADsPath
  35. )
  36. {
  37. HRESULT hr;
  38. IADs * pADs = NULL;
  39. hr = ADsGetObject(
  40. szADsPath,
  41. IID_IADs,
  42. (void **)&pADs
  43. );
  44. BAIL_ON_FAILURE(hr);
  45. hr = DumpObject(pADs);
  46. error:
  47. if (pADs)
  48. pADs->Release();
  49. return hr;
  50. }
  51. HRESULT
  52. DumpObject(
  53. IADs * pADs
  54. )
  55. {
  56. HRESULT hr;
  57. IADs * pADsProp = NULL;
  58. VARIANT * pVariantArray = NULL;
  59. VARIANT varProperty;
  60. DWORD dwNumProperties = 0;
  61. BSTR bstrPropName = NULL;
  62. DWORD i = 0;
  63. IDispatch * pDispatch = NULL;
  64. hr = GetPropertyList(
  65. pADs,
  66. &pVariantArray,
  67. &dwNumProperties
  68. );
  69. BAIL_ON_FAILURE(hr);
  70. //
  71. // printf("GetPropertyList here\n");
  72. //
  73. hr = pADs->GetInfo();
  74. BAIL_ON_FAILURE(hr);
  75. //
  76. // printf("GetInfo succeeded \n");
  77. //
  78. for (i = 0; i < dwNumProperties; i++ ) {
  79. pDispatch = (pVariantArray + i)->pdispVal;
  80. hr = pDispatch->QueryInterface(
  81. IID_IADs,
  82. (void **)&pADsProp
  83. );
  84. BAIL_ON_FAILURE(hr);
  85. pDispatch->Release(); // NEW
  86. hr = pADsProp->get_Name(&bstrPropName);
  87. pADsProp->Release(); // NEW
  88. BAIL_ON_FAILURE(hr);
  89. hr = pADs->Get(
  90. bstrPropName,
  91. &varProperty
  92. );
  93. PrintProperty(
  94. bstrPropName,
  95. hr,
  96. varProperty
  97. );
  98. //
  99. // printf("PrintProperty succeeded \n");
  100. //
  101. if (bstrPropName) {
  102. SysFreeString(bstrPropName);
  103. }
  104. }
  105. error:
  106. free(pVariantArray);
  107. return(hr);
  108. }
  109. //
  110. // Exec function definitions
  111. //
  112. int
  113. ExecDump(char *szProgName, char *szAction, int argc, char * argv[])
  114. {
  115. HRESULT hr;
  116. LPWSTR szADsPath = NULL;
  117. if (argc != 1) {
  118. PrintUsage(szProgName, szAction, "<ADsPath>");
  119. return 1;
  120. }
  121. szADsPath = AllocateUnicodeString(argv[0]);
  122. hr = ListProperties(
  123. szADsPath
  124. );
  125. FreeUnicodeString(szADsPath);
  126. if (FAILED(hr))
  127. return 1;
  128. return 0;
  129. }
  130. /*
  131. int
  132. ExecListTransient(char *szProgName, char *szAction, int argc, char * argv[])
  133. {
  134. HRESULT hr;
  135. LPWSTR szADsPath = NULL;
  136. LPWSTR szObjectType = NULL;
  137. if (argc != 2) {
  138. PrintUsage(szProgName, szAction,
  139. "<ADsPath> [ job | session | resource ]");
  140. return (1);
  141. }
  142. szADsPath = AllocateUnicodeString(argv[0]);
  143. szObjectType = AllocateUnicodeString(argv[1]);
  144. hr = EnumTransientObjects(
  145. szADsPath,
  146. szObjectType,
  147. TRUE
  148. );
  149. error:
  150. FreeUnicodeString(szADsPath);
  151. FreeUnicodeString(szObjectType);
  152. if (FAILED(hr)) {
  153. printf("Enumerate transient objects failed\n");
  154. return(1);
  155. }
  156. printf("Enumerate transient objects succeeded\n");
  157. return(0);
  158. }
  159. */