Leaked source code of windows server 2003
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.

169 lines
4.7 KiB

  1. // Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  2. //
  3. // CMDH.cpp - Helper class for working with
  4. // logical disks mapped by logon
  5. // session.
  6. //
  7. // Created: 4/23/2000 Kevin Hughes (khughes)
  8. //
  9. #pragma once
  10. #define STR_FROM_bool(x) ( x ? L"TRUE" : L"FALSE" )
  11. _COM_SMARTPTR_TYPEDEF(IDiskQuotaControl, IID_IDiskQuotaControl);
  12. #define GET_NOTHING 0x00000000
  13. #define GET_ALL_PROPERTIES 0xFFFFFFFF
  14. #define GET_DEVICEID 0x00000001
  15. #define GET_PROVIDER_NAME 0x00000002
  16. #define GET_VOLUME_NAME 0x00000004
  17. #define GET_FILE_SYSTEM 0x00000008
  18. #define GET_VOLUME_SERIAL_NUMBER 0x00000010
  19. #define GET_COMPRESSED 0x00000020
  20. #define GET_SUPPORTS_FILE_BASED_COMPRESSION 0x00000040
  21. #define GET_MAXIMUM_COMPONENT_LENGTH 0x00000080
  22. #define GET_SUPPORTS_DISK_QUOTAS 0x00000100
  23. #define GET_QUOTAS_INCOMPLETE 0x00000200
  24. #define GET_QUOTAS_REBUILDING 0x00000400
  25. #define GET_QUOTAS_DISABLED 0x00000800
  26. #define GET_PERFORM_AUTOCHECK 0x00001000
  27. #define GET_FREE_SPACE 0x00002000
  28. #define GET_SIZE 0x00004000
  29. #define GET_VOL_INFO (GET_VOLUME_NAME | \
  30. GET_FILE_SYSTEM | \
  31. GET_VOLUME_SERIAL_NUMBER | \
  32. GET_COMPRESSED | \
  33. GET_SUPPORTS_FILE_BASED_COMPRESSION | \
  34. GET_MAXIMUM_COMPONENT_LENGTH | \
  35. GET_SUPPORTS_DISK_QUOTAS | \
  36. GET_QUOTAS_INCOMPLETE | \
  37. GET_QUOTAS_REBUILDING | \
  38. GET_QUOTAS_DISABLED | \
  39. GET_PERFORM_AUTOCHECK)
  40. #define SPIN_DISK (GET_VOL_INFO | \
  41. GET_FREE_SPACE | \
  42. GET_SIZE)
  43. enum
  44. {
  45. PROP_DEVICEID = 0,
  46. PROP_PROVIDER_NAME = 1,
  47. PROP_VOLUME_NAME = 2,
  48. PROP_FILE_SYSTEM = 3,
  49. PROP_VOLUME_SERIAL_NUMBER = 4,
  50. PROP_COMPRESSED = 5,
  51. PROP_SUPPORTS_FILE_BASED_COMPRESSION = 6,
  52. PROP_MAXIMUM_COMPONENT_LENGTH = 7,
  53. PROP_SUPPORTS_DISK_QUOTAS = 8,
  54. PROP_QUOTAS_INCOMPLETE = 9,
  55. PROP_QUOTAS_REBUILDING = 10,
  56. PROP_QUOTAS_DISABLED = 11,
  57. PROP_PERFORM_AUTOCHECK = 12,
  58. PROP_FREE_SPACE = 13,
  59. PROP_SIZE = 14,
  60. PROP_COUNT = 15
  61. };
  62. class CMDH
  63. {
  64. public:
  65. CMDH() : m_dwImpPID(-1L) {}
  66. CMDH(
  67. DWORD dwPID)
  68. : m_dwImpPID(dwPID)
  69. {}
  70. virtual ~CMDH() {}
  71. HRESULT GetMDData(
  72. DWORD dwReqProps,
  73. VARIANT* pvarData);
  74. HRESULT GetOneMDData(
  75. BSTR bstrDrive,
  76. DWORD dwReqProps,
  77. VARIANT* pvarData);
  78. DWORD GetImpPID()
  79. {
  80. return m_dwImpPID;
  81. }
  82. void SetImpPID(
  83. DWORD dwPID)
  84. {
  85. m_dwImpPID = dwPID;
  86. }
  87. private:
  88. HRESULT GetMappedDisksAndData(
  89. DWORD dwReqProps,
  90. VARIANT* pvarData);
  91. HRESULT GetSingleMappedDiskAndData(
  92. BSTR bstrDrive,
  93. DWORD dwReqProps,
  94. VARIANT* pvarData);
  95. #ifdef NTONLY
  96. void GetMappedDriveList(
  97. std::vector<_bstr_t>& vecMappedDrives);
  98. #endif
  99. HRESULT GetMappedDriveInfo(
  100. LPCWSTR wstrDriveName,
  101. long lDrivePropArrayDriveIndex,
  102. SAFEARRAY* saDriveProps,
  103. DWORD dwReqProps);
  104. HRESULT GetProviderName(
  105. LPCWSTR wstrDriveName,
  106. long lDrivePropArrayDriveIndex,
  107. SAFEARRAY* saDriveProps);
  108. HRESULT GetDriveVolumeInformation(
  109. LPCWSTR wstrDriveName,
  110. long lDrivePropArrayDriveIndex,
  111. SAFEARRAY* saDriveProps);
  112. BOOLEAN IsVolumeDirty(
  113. _bstr_t &bstrtNtDriveName,
  114. BOOLEAN *Result);
  115. HRESULT GetDriveFreeSpace(
  116. LPCWSTR wstrDriveName,
  117. long lDrivePropArrayDriveIndex,
  118. SAFEARRAY* saDriveProps);
  119. HRESULT SetProperty(
  120. long lDrivePropArrayDriveIndex,
  121. long lDrivePropArrayPropIndex,
  122. LPCWSTR wstrPropValue,
  123. SAFEARRAY* saDriveProps);
  124. HANDLE Impersonate();
  125. DWORD m_dwImpPID;
  126. };