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.

101 lines
1.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: idlhelp.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "pch.h"
  11. #pragma hdrstop
  12. #include <shsemip.h> // ILFree(), etc
  13. #include "idlhelp.h"
  14. #include "folder.h"
  15. HRESULT
  16. IsOfflineFilesFolderID(
  17. LPCITEMIDLIST pidl
  18. )
  19. {
  20. LPITEMIDLIST pidlOfflineFilesFolder;
  21. HRESULT hr = COfflineFilesFolder::CreateIDList(&pidlOfflineFilesFolder);
  22. if (SUCCEEDED(hr))
  23. {
  24. if (ILIsEqual(pidlOfflineFilesFolder, pidl))
  25. hr = S_OK;
  26. else
  27. hr = S_FALSE;
  28. ILFree(pidlOfflineFilesFolder);
  29. }
  30. return hr;
  31. }
  32. HRESULT
  33. BindToObject(
  34. IShellFolder *psf,
  35. REFIID riid,
  36. LPCITEMIDLIST pidl,
  37. void **ppvOut
  38. )
  39. {
  40. HRESULT hr = NOERROR;
  41. IShellFolder *psfRelease = NULL;
  42. if (!psf)
  43. {
  44. hr = SHGetDesktopFolder(&psf);
  45. if (SUCCEEDED(hr))
  46. {
  47. psfRelease = psf;
  48. }
  49. }
  50. if (SUCCEEDED(hr))
  51. {
  52. if (!pidl || ILIsEmpty(pidl))
  53. hr = psf->QueryInterface(riid, ppvOut);
  54. else
  55. hr = psf->BindToObject(pidl, NULL, riid, ppvOut);
  56. }
  57. if (psfRelease)
  58. psfRelease->Release();
  59. return hr;
  60. }
  61. HRESULT
  62. BindToIDListParent(
  63. LPCITEMIDLIST pidl,
  64. REFIID riid,
  65. void **ppv,
  66. LPCITEMIDLIST *ppidlLast
  67. )
  68. {
  69. HRESULT hr;
  70. LPITEMIDLIST pidlParent = ILClone(pidl);
  71. if (pidlParent)
  72. {
  73. ILRemoveLastID(pidlParent);
  74. hr = ::BindToObject(NULL, riid, (LPCITEMIDLIST)pidlParent, ppv);
  75. if (SUCCEEDED(hr))
  76. {
  77. if (ppidlLast)
  78. *ppidlLast = ILFindLastID(pidl);
  79. }
  80. ILFree(pidlParent);
  81. }
  82. else
  83. hr = E_OUTOFMEMORY;
  84. return hr;
  85. }