native.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 2k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. //
  2. //  native.cpp in shelllib
  3. //  
  4. //  common Utility functions that need to be compiled for 
  5. //  both UNICODE and ANSI
  6. //
  7. #include "proj.h"
  8. #include <vdate.h>
  9. // get the name and flags of an absolute IDlist
  10. // in:
  11. //      dwFlags     SHGDN_ flags as hints to the name space GetDisplayNameOf() function
  12. //
  13. // in/out:
  14. //      *pdwAttribs (optional) return flags
  15. STDAPI SHGetNameAndFlags(LPCITEMIDLIST pidl, DWORD dwFlags, LPTSTR pszName, UINT cchName, DWORD *pdwAttribs)
  16. {
  17.     if (pszName)
  18.     {
  19.         VDATEINPUTBUF(pszName, TCHAR, cchName);
  20.         *pszName = 0;
  21.     }
  22.     HRESULT hrInit = SHCoInitialize();
  23.     IShellFolder *psf;
  24.     LPCITEMIDLIST pidlLast;
  25.     HRESULT hres = SHBindToIDListParent(pidl, IID_IShellFolder, (void **)&psf, &pidlLast);
  26.     if (SUCCEEDED(hres))
  27.     {
  28.         if (pszName)
  29.         {
  30.             STRRET str;
  31.             hres = psf->GetDisplayNameOf(pidlLast, dwFlags, &str);
  32.             if (SUCCEEDED(hres))
  33.                 hres = StrRetToBuf(&str, pidlLast, pszName, cchName);
  34.         }
  35.         if (SUCCEEDED(hres) && pdwAttribs)
  36.         {
  37.             RIP(*pdwAttribs);    // this is an in-out param
  38.             hres = psf->GetAttributesOf(1, (LPCITEMIDLIST *)&pidlLast, pdwAttribs);
  39.         }
  40.         psf->Release();
  41.     }
  42.     SHCoUninitialize(hrInit);
  43.     return hres;
  44. }
  45. STDAPI_(DWORD) GetUrlScheme(LPCTSTR pszUrl)
  46. {
  47.     if(pszUrl)
  48.     {
  49.         PARSEDURL pu;
  50.         pu.cbSize = SIZEOF(pu);
  51.         if(SUCCEEDED(ParseURL(pszUrl, &pu)))
  52.             return pu.nScheme;
  53.     }
  54.     return URL_SCHEME_INVALID;
  55. }