Leaked source code of windows server 2003
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.

156 lines
7.3 KiB

  1. /**************************************************************\
  2. FILE: shellurl.h
  3. DESCRIPTION:
  4. Handle dealing with Shell Urls. Include: Generating from PIDL,
  5. Generating from preparsed Url String, and parsing from a user
  6. entered Url String.
  7. \**************************************************************/
  8. #ifndef _SHELLURL_H
  9. #define _SHELLURL_H
  10. #define STR_REGKEY_APPPATH TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths")
  11. // Parameters for ::SetUrl()'s dwGenType parameter
  12. #define GENTYPE_FROMPATH 0x00000001
  13. #define GENTYPE_FROMURL 0x00000002
  14. class CShellUrl;
  15. BOOL IsShellUrl(LPCTSTR pcszUrl, BOOL fIncludeFileUrls);
  16. BOOL IsSpecialFolderChild(LPCITEMIDLIST pidlToTest, int nFolder, BOOL fImmediate);
  17. HRESULT SetDefaultShellPath(CShellUrl * psu);
  18. /**************************************************************\
  19. CLASS: CShellUrl
  20. DESCRIPTION:
  21. This object was created to keep track of a FULL SHELL URL.
  22. This includes any object in the shell name space and how
  23. to interact with that object. Objects can be specified as
  24. PIDLs and then will be handled appropriately when executed,
  25. which means it will Navigate to the object if the object
  26. supports navigation or "browse in place" (registered DocHost,
  27. Shell Folder, Internet URL)
  28. otherwise the Shell Url will be executed (files, shell items).
  29. If a string is inputed by the user, the ::ParseFromOutsideSource()
  30. method should be called. This will take all of the environment
  31. information into consideration (CurrWorkDir & Path) and parse
  32. the URL. If the string needs to be shell executed, it will
  33. generate the command line arguments and current working directory
  34. string. If the object is to be navigated to, it will determine
  35. the navigation flags (for AutoSearch and similar things).
  36. PERF:
  37. This object was build so that if you specify a PIDL or String,
  38. it should be able to hold that information without a perf hit.
  39. If you want to take advantage of ::ParseFromOutsideSource() or
  40. ::Execute(), it will require a little more CPU time to do the
  41. full functionality.
  42. GOAL:
  43. The goal of the parsing is to make it into a normal internet
  44. URL unless the algorithm can with certainty assume that the string
  45. entered is specifying a Shell Name Space item or action. This means
  46. that CShellUrl will only assume the entered text is a Shell Item to be
  47. Navigated to if it can successfully bind to the destination pidl.
  48. It will assume it's an item to be executed and use the end of the
  49. string as Command Line Arguments if: 1) It can bind to the end PIDL,
  50. and 2) The end pidl is not "Browsable" or "Navigatible", and 3)
  51. the char after the string specifying the PIDL is a Space.
  52. \**************************************************************/
  53. class CShellUrl : public IAddressBarParser
  54. {
  55. public:
  56. // *** IUnknown ***
  57. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  58. STDMETHODIMP_(ULONG) AddRef(void);
  59. STDMETHODIMP_(ULONG) Release(void);
  60. // IAddressBarParser
  61. STDMETHODIMP ParseFromOutsideSource(LPCTSTR pcszUrlIn, DWORD dwParseFlags, PBOOL pfWasCorrected = NULL, PBOOL pfWasCanceled = NULL);
  62. STDMETHODIMP GetUrl(LPTSTR pszUrlOut, DWORD cchUrlOutSize);
  63. STDMETHODIMP SetUrl(LPCTSTR pcszUrlIn, DWORD dwGenType); // Reset CShellUrl to this URL
  64. STDMETHODIMP GetDisplayName(LPTSTR pszUrlOut, DWORD cchUrlOutSize);
  65. STDMETHODIMP GetPidl(LPITEMIDLIST * ppidl);
  66. STDMETHODIMP SetPidl(LPCITEMIDLIST pidl); // Reset CShellUrl to this PIDL
  67. STDMETHODIMP GetArgs(LPTSTR pszArgsOut, DWORD cchArgsOutSize);
  68. STDMETHODIMP AddPath(LPCITEMIDLIST pidl);
  69. // Constructor / Destructor
  70. CShellUrl();
  71. ~CShellUrl(void);
  72. HRESULT Clone(CShellUrl * pShellUrl);
  73. HRESULT Execute(IBandProxy * pbp, BOOL * pfDidShellExec, DWORD dwExecFlags);
  74. BOOL IsWebUrl(void);
  75. HRESULT SetCurrentWorkingDir(LPCITEMIDLIST pidlCWD);
  76. HRESULT Reset(void);
  77. void SetMessageBoxParent(HWND hwnd);
  78. #ifdef UNICODE
  79. HRESULT ParseFromOutsideSource(LPCSTR pcszUrlIn, DWORD dwParseFlags, PBOOL pfWasCorrected);
  80. #endif // UNICODE
  81. HRESULT GetPidlNoGenerate(LPITEMIDLIST * ppidl);
  82. private:
  83. // Parsing Methods
  84. HRESULT _ParseRelativePidl(LPCTSTR pcszUrlIn, BOOL * pfPossibleWebUrl, DWORD dwFlags, LPCITEMIDLIST pidl, BOOL fAllowRelative, BOOL fQualifyDispName);
  85. HRESULT _ParseUNC(LPCTSTR pcszUrlIn, BOOL * pfPossibleWebUrl, DWORD dwFlags, BOOL fQualifyDispName);
  86. HRESULT _ParseSeparator(LPCITEMIDLIST pidlParent, LPCTSTR pcszSeg, BOOL * pfPossibleWebUrl, BOOL fAllowRelative, BOOL fQualifyDispName);
  87. HRESULT _ParseNextSegment(LPCITEMIDLIST pidlParent, LPCTSTR pcszStrToParse, BOOL * pfPossibleWebUrl, BOOL fAllowRelative, BOOL fQualifyDispName);
  88. HRESULT _CheckItem(IShellFolder * psfFolder, LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlRelative,
  89. LPITEMIDLIST * ppidlChild, LPCTSTR pcszStrToParse, LPTSTR * ppszRemaining, DWORD dwFlags);
  90. HRESULT _GetNextPossibleSegment(LPCTSTR pcszFullPath, LPTSTR * ppszSegIterator, LPTSTR pszSegOut, DWORD cchSegOutSize, BOOL fSkipShare);
  91. HRESULT _GetNextPossibleFullPath(LPCTSTR pcszFullPath, LPTSTR * ppszSegIterator, LPTSTR pszSegOut, DWORD cchSegOutSize, BOOL * pfContinue);
  92. HRESULT _QualifyFromPath(LPCTSTR pcszFilePathIn, DWORD dwFlags);
  93. HRESULT _QualifyFromDOSPath(LPCTSTR pcszFilePathIn, DWORD dwFlags);
  94. HRESULT _QualifyFromAppPath(LPCTSTR pcszFilePathIn, DWORD dwFlags);
  95. HRESULT _QuickParse(LPCITEMIDLIST pidlParent, LPTSTR pszParseChunk, LPTSTR pszNext, BOOL * pfPossibleWebUrl, BOOL fAllowRelative, BOOL fQualifyDispName);
  96. BOOL _CanUseAdvParsing(void);
  97. BOOL _ParseURLFromOutsideSource(LPCWSTR psz, LPWSTR pszOut, LPDWORD pcchOut, LPBOOL pbWasSearchURL, LPBOOL pbWasCorrected);
  98. HRESULT _TryQuickParse(LPCTSTR pszUrl, DWORD dwParseFlags);
  99. // Accessor Methods
  100. HRESULT _SetPidl(LPCITEMIDLIST pidl); // Set PIDL w/o modifying URL
  101. HRESULT _GeneratePidl(LPCTSTR pcszUrl, DWORD dwGenType);
  102. HRESULT _SetUrl(LPCTSTR pcszUrlIn, DWORD dwGenType); // Set URL w/o modifying PIDL
  103. HRESULT _GenerateUrl(LPCITEMIDLIST pidl);
  104. HRESULT _GenDispNameFromPidl(LPCITEMIDLIST pidl, LPCTSTR pcszArgs);
  105. // Other Methods
  106. HRESULT _PidlShellExec(LPCITEMIDLIST pidl, ULONG ulShellExecFMask);
  107. HRESULT _UrlShellExec(void);
  108. BOOL _IsFilePidl(LPCITEMIDLIST pidl);
  109. HWND _GetWindow(void) { return (IsFlagSet(m_dwFlags, SHURL_FLAGS_NOUI) ? NULL : GetDesktopWindow()); }
  110. //////////////////////////////////////////////////////
  111. // Private Member Variables
  112. //////////////////////////////////////////////////////
  113. LPTSTR m_pszURL;
  114. LPTSTR m_pszDisplayName; // The nice display name of the entity.
  115. LPTSTR m_pszArgs;
  116. LPTSTR m_pstrRoot;
  117. LPITEMIDLIST m_pidl;
  118. DWORD m_dwGenType;
  119. DWORD m_dwFlags;
  120. LPITEMIDLIST m_pidlWorkingDir;
  121. HDPA m_hdpaPath; // DPA of PIDLs
  122. HWND m_hwnd; // parent window for message boxes
  123. LONG _cRef;
  124. };
  125. #endif /* _SHELLURL_H */