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.

118 lines
2.8 KiB

  1. /*
  2. * pidl - PIDLs and diddles
  3. *
  4. */
  5. #include "tweakui.h"
  6. #pragma BEGIN_CONST_DATA
  7. #pragma END_CONST_DATA
  8. /*****************************************************************************
  9. *
  10. * pidlFromPath
  11. *
  12. * Create a pidl from an psf and a relative path.
  13. *
  14. *****************************************************************************/
  15. PIDL PASCAL
  16. pidlFromPath(LPSHELLFOLDER psf, LPCTSTR lqn)
  17. {
  18. PIDL pidl;
  19. UnicodeFromPtsz(wsz, lqn);
  20. if (SUCCEEDED(psf->ParseDisplayName(0, 0, wsz, 0, &pidl, 0))) {
  21. return pidl;
  22. } else {
  23. return 0;
  24. }
  25. }
  26. /*****************************************************************************
  27. *
  28. * pidlSimpleFromPath
  29. *
  30. * Create a simple pidl from an psf and a relative path.
  31. *
  32. *****************************************************************************/
  33. PIDL PASCAL
  34. pidlSimpleFromPath(LPCTSTR lqn)
  35. {
  36. PIDL pidl;
  37. if (g_fNT) {
  38. UnicodeFromPtsz(wsz, lqn);
  39. return mit.SHSimpleIDListFromPath(wsz);
  40. } else {
  41. AnsiFromPtsz(sz, lqn);
  42. return mit.SHSimpleIDListFromPath(sz);
  43. }
  44. }
  45. /*****************************************************************************
  46. *
  47. * SetNameOfPidl
  48. *
  49. * Change a pidl's name.
  50. *
  51. *****************************************************************************/
  52. HRESULT PASCAL
  53. SetNameOfPidl(PSF psf, PIDL pidl, LPCTSTR ptszName)
  54. {
  55. UnicodeFromPtsz(wsz, ptszName);
  56. return psf->SetNameOf(0, pidl, wsz, 0, 0);
  57. }
  58. /*****************************************************************************
  59. *
  60. * ComparePidls
  61. *
  62. * Compare two pidls.
  63. *
  64. *****************************************************************************/
  65. HRESULT PASCAL
  66. ComparePidls(PIDL pidl1, PIDL pidl2)
  67. {
  68. return psfDesktop->CompareIDs(0, pidl1, pidl2);
  69. }
  70. /*****************************************************************************
  71. *
  72. * GetSystemImageList
  73. *
  74. * Get the large or small image list handle.
  75. *
  76. * The dword argument is 0 for the large image list, or
  77. * SHGFI_SMALLICON for the small image list.
  78. *
  79. *****************************************************************************/
  80. HIML PASCAL
  81. GetSystemImageList(DWORD dw)
  82. {
  83. SHFILEINFO sfi;
  84. return (HIML)SHGetFileInfo(g_tszPathShell32, FILE_ATTRIBUTE_DIRECTORY,
  85. &sfi, sizeof(sfi), SHGFI_USEFILEATTRIBUTES |
  86. SHGFI_SYSICONINDEX | dw);
  87. }
  88. /*****************************************************************************
  89. *
  90. * ChangeNotifyCsidl
  91. *
  92. * Send a SHChangeNotify based on a CSIDL.
  93. *
  94. *****************************************************************************/
  95. STDAPI_(void)
  96. ChangeNotifyCsidl(HWND hwnd, int csidl, LONG eventId)
  97. {
  98. PIDL pidl;
  99. if (SUCCEEDED(SHGetSpecialFolderLocation(hwnd, csidl, &pidl))) {
  100. SHChangeNotify(eventId, SHCNF_IDLIST, pidl, 0L);
  101. Ole_Free(pidl);
  102. }
  103. }