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.

203 lines
6.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: U P D P I D L . H
  7. //
  8. // Contents: UP Device Folder structures, classes, and prototypes
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 11 Nov 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _UPDPIDL_H_
  17. #define _UPDPIDL_H_
  18. // Max sizes of our pidl fields
  19. //
  20. // $$REVIEW:
  21. //
  22. #define MAX_UPnPDeviceName MAX_PATH
  23. #define MAX_UPnPURL MAX_PATH
  24. #define MAX_UPnPUDN MAX_PATH
  25. #define MAX_UPnPType MAX_PATH
  26. #define MAX_UPnPDescription MAX_PATH
  27. typedef LPITEMIDLIST PUPNPDEVICEFOLDPIDL;
  28. // Pidl Version Definition
  29. //
  30. // This defines the version number of the ConFoldPidl structure. When this
  31. // changes, we'll need to invalidate the entries.
  32. // This has the following format:
  33. // +-----------+-----------+
  34. // | HIGH WORD | LOW WORD |
  35. // +-----------+-----------+
  36. // current lowest
  37. // version version
  38. // "current version" : the version of the shell code which
  39. // created the PIDL
  40. // "lowest version": the lowest version of the shell code
  41. // which can read the PIDL
  42. // example: shell code version "1" can read a PIDL marked
  43. // as "0x00030001" but not one marked as "0x00050003".
  44. // shell code version "3" can read a PIDL marked
  45. // as "0x00030001" and get more information from it
  46. // than a version "1" client.
  47. //
  48. #define UP_DEVICE_FOLDER_IDL_VERSION 0x00010001
  49. class CUPnPDeviceFoldPidl
  50. {
  51. public:
  52. CUPnPDeviceFoldPidl();
  53. ~CUPnPDeviceFoldPidl();
  54. HRESULT HrInit(FolderDeviceNode * pDeviceNode);
  55. HRESULT HrInit(PUPNPDEVICEFOLDPIDL pPidl);
  56. HRESULT HrPersist(IMalloc * pMalloc, LPITEMIDLIST * ppidl);
  57. PCWSTR PszGetNamePointer() const;
  58. PCWSTR PszGetURLPointer() const;
  59. PCWSTR PszGetUDNPointer() const;
  60. PCWSTR PszGetTypePointer() const;
  61. PCWSTR PszGetDescriptionPointer() const;
  62. HRESULT HrSetName(PCWSTR szName);
  63. private:
  64. /* this is the structure of our PIDLs, in byte-order. All
  65. numbers are saved as big-endian unsigned integers.
  66. 0 1 2 3 4 5 6 7 <- byte
  67. | | | | | | | | |
  68. +===============================+
  69. | iCB |uLeadId| dwVersion |
  70. +-------------------------------+
  71. |uTrlId | VOID | dwUnusedFlags |
  72. +-------------------------------+
  73. | ulNameOffset | cbName |
  74. +-------------------------------+
  75. | ulUrlOffset | cbUrl |
  76. +-------------------------------+
  77. | ulUdnOffset | cbUdn |
  78. +-------------------------------+
  79. | ulTypeOffset | cbType |
  80. +-------------------------------+
  81. | ulDescOffset | cbDesc |
  82. +-------------------------------+
  83. | set of NULL-terminated |
  84. | unicode strings, byte-packed. |
  85. | The offset and length of a |
  86. | given string is specified by |
  87. | the headers above... |
  88. / /
  89. +-------------------------------+
  90. | 0 |
  91. +-------+
  92. the names in the table above represent
  93. the following:
  94. iCB: Total size of the structure
  95. (including iCB itself).
  96. [note: Milennium seems to
  97. miscalculate this field, always
  98. storing a value two greater than
  99. what it really is. Oops.
  100. If the "highest version" is
  101. specified as 1, this bug should
  102. be assumed.]
  103. ulLeadId: Always UPNPDEVICEFOLDPIDL_LEADID
  104. dwVersion: the min/max versions of the PIDL,
  105. as described in "Pidl Version Definition"
  106. above.
  107. uTrlId: Always UPNPDEVICEFOLDPIDL_TRAILID
  108. VOID: Not usable - these bytes are garbage
  109. and can never be used
  110. dwUnusedFlags: Flags for future use. These
  111. are currently always set to zero.
  112. ulNameOffset,
  113. ulUrlOffset,
  114. etc.: Offset of the string fields stored
  115. in the variable-length section. The
  116. offset given is relative to the start
  117. of the variable-length section, not
  118. from the start of the entire structure.
  119. cbName, cbUrl,
  120. etc.: Length, in bytes, of each string in
  121. the variable-length section.
  122. */
  123. LPWSTR m_pszName;
  124. LPWSTR m_pszUrl;
  125. LPWSTR m_pszUdn;
  126. LPWSTR m_pszType;
  127. LPWSTR m_pszDesc;
  128. };
  129. // IMPORTANT: you MUST declare pointers to this structure
  130. // as UNALIGNED, or using it will break on win64, and
  131. // cause performance degredation on axp
  132. //
  133. # pragma pack (1)
  134. struct UPNPUI_PIDL_HEADER
  135. {
  136. WORD iCB; // 2 bytes
  137. USHORT uLeadId; // 2 bytes
  138. DWORD dwVersion; // 4 bytes
  139. USHORT uTrailId; // 2 bytes
  140. USHORT uVOID; // 2 bytes
  141. DWORD dwCharacteristics; // 4 bytes
  142. ULONG ulNameOffset; // 4 bytes
  143. ULONG cbName; // etc...
  144. ULONG ulUrlOffset;
  145. ULONG cbUrl;
  146. ULONG ulUdnOffset;
  147. ULONG cbUdn;
  148. ULONG ulTypeOffset;
  149. ULONG cbType;
  150. ULONG ulDescOffset;
  151. ULONG cbDesc;
  152. };
  153. # pragma pack ()
  154. // One of our pidls must be at least this size, it will likely be bigger.
  155. //
  156. #define CBUPNPDEVICEFOLDPIDL_MIN sizeof(UPNPUI_PIDL_HEADER)
  157. // More versioning info. This will help me identify PIDLs as being mine
  158. //
  159. #define UPNPDEVICEFOLDPIDL_LEADID 0x6EFF
  160. #define UPNPDEVICEFOLDPIDL_TRAILID 0x7EFF
  161. #define UPNPDEVICEFOLDPIDL_MINVER(x) (LOWORD(x))
  162. #define UPNPDEVICEFOLDPIDL_MAXVER(x) (HIWORD(x))
  163. PUPNPDEVICEFOLDPIDL ConvertToUPnPDevicePIDL(LPCITEMIDLIST pidl);
  164. BOOL FIsUPnPDeviceFoldPidl(LPCITEMIDLIST pidl);
  165. HRESULT HrMakeUPnPDevicePidl(
  166. LPWSTR pszName,
  167. LPWSTR pszURL,
  168. LPWSTR pszUDN,
  169. LPWSTR pszType,
  170. LPWSTR pszDescription,
  171. LPITEMIDLIST * ppidl);
  172. #endif // _UPDPIDL_H_