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.

102 lines
2.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: C F P I D L . C P P
  7. //
  8. // Contents: Connections Folder structures and classes.
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 11 Nov 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. //+---------------------------------------------------------------------------
  18. //
  19. // Function: ConvertToUPnPDevicePIDL
  20. //
  21. // Purpose: Convert a pidl to UPNPDEVICEFOLDPIDL
  22. //
  23. // Arguments:
  24. // pidl [] PIDL to convert
  25. //
  26. //
  27. // Returns: The converted pidl
  28. //
  29. // Author: tongl 16 Feb 2000
  30. //
  31. // Notes:
  32. //
  33. //
  34. PUPNPDEVICEFOLDPIDL ConvertToUPnPDevicePIDL(LPCITEMIDLIST pidl)
  35. {
  36. return reinterpret_cast<PUPNPDEVICEFOLDPIDL>
  37. (ILSkip(pidl, FIELD_OFFSET(DELEGATEITEMID, rgb)));
  38. }
  39. //+---------------------------------------------------------------------------
  40. //
  41. // Function: FIsUPnPDeviceFoldPidl
  42. //
  43. // Purpose: Determine whether a particular PIDL is a UPNPDEVICEFOLDPIDL
  44. //
  45. // Arguments:
  46. // pidl [] PIDL to test
  47. //
  48. //
  49. // Returns: TRUE if it is a UPNPDEVICEFOLDPIDL, FALSE otherwise
  50. //
  51. // Author: jeffspr 24 Oct 1997
  52. //
  53. // Notes: tongl 2/16/00: use the ConvertToUPnPDevicePIDL as we are
  54. // a delegate folder now
  55. //
  56. //
  57. BOOL FIsUPnPDeviceFoldPidl(LPCITEMIDLIST pidl)
  58. {
  59. BOOL fReturn = FALSE;
  60. if (pidl)
  61. {
  62. PUPNPDEVICEFOLDPIDL pudfp = ConvertToUPnPDevicePIDL(pidl);
  63. UNALIGNED UPNPUI_PIDL_HEADER * puph;
  64. puph = (UPNPUI_PIDL_HEADER *)pudfp;
  65. if (puph->iCB >= CBUPNPDEVICEFOLDPIDL_MIN)
  66. {
  67. if (puph->uLeadId == UPNPDEVICEFOLDPIDL_LEADID &&
  68. puph->uTrailId == UPNPDEVICEFOLDPIDL_TRAILID)
  69. {
  70. if (UPNPDEVICEFOLDPIDL_MINVER(puph->dwVersion) <=
  71. UPNPDEVICEFOLDPIDL_MINVER(UP_DEVICE_FOLDER_IDL_VERSION))
  72. {
  73. fReturn = TRUE;
  74. }
  75. else
  76. {
  77. TraceTag(ttidShellFolder, "Pidl version (0x%x) != UP_DEVICE_FOLDER_IDL_VERSION (0x%x)",
  78. puph->dwVersion, UP_DEVICE_FOLDER_IDL_VERSION);
  79. }
  80. }
  81. else
  82. {
  83. TraceTag(ttidShellFolder, "Pidl format != connections pidl format. Lead or trail ID not found");
  84. }
  85. }
  86. else
  87. {
  88. TraceTag(ttidShellFolder, "Pidl size inconsistent with UPNPDEVICEFOLDPIDL");
  89. }
  90. }
  91. else
  92. {
  93. TraceTag(ttidShellFolder, "Pidl NULL in FIsUPnPDeviceFoldPidl");
  94. }
  95. return fReturn;
  96. }