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.

191 lines
6.8 KiB

  1. /*
  2. * intshcut.hpp - Internet Shortcut class implementation description.
  3. */
  4. /* Types
  5. ********/
  6. // InternetShortcut flags
  7. typedef enum _intshcutflags
  8. {
  9. INTSHCUT_FL_DIRTY = 0x0001,
  10. ALL_INTSHCUT_FLAGS = INTSHCUT_FL_DIRTY
  11. }
  12. INTSHCUTFLAGS;
  13. // InternetShortcut Shell extension
  14. class InternetShortcut : public RefCount,
  15. public IDataObject,
  16. public IExtractIcon,
  17. public INewShortcutHook,
  18. public IPersistFile,
  19. public IPersistStream,
  20. public IShellExecuteHook,
  21. public IShellExtInit,
  22. public IShellLink,
  23. public IShellPropSheetExt,
  24. public IUniformResourceLocator
  25. {
  26. private:
  27. DWORD m_dwFlags;
  28. PSTR m_pszFile;
  29. PSTR m_pszURL;
  30. PSTR m_pszIconFile;
  31. int m_niIcon;
  32. PSTR m_pszWorkingDirectory;
  33. int m_nShowCmd;
  34. PSTR m_pszFolder;
  35. WORD m_wHotkey;
  36. // data transfer methods
  37. DWORD STDMETHODCALLTYPE GetFileContentsSize(void);
  38. HRESULT STDMETHODCALLTYPE TransferUniformResourceLocator(PFORMATETC pfmtetc, PSTGMEDIUM pstgmed);
  39. HRESULT STDMETHODCALLTYPE TransferText(PFORMATETC pfmtetc, PSTGMEDIUM pstgmed);
  40. HRESULT STDMETHODCALLTYPE TransferFileGroupDescriptor(PFORMATETC pfmtetc, PSTGMEDIUM pstgmed);
  41. HRESULT STDMETHODCALLTYPE TransferFileContents(PFORMATETC pfmtetc, PSTGMEDIUM pstgmed);
  42. // protocol registration methods
  43. HRESULT STDMETHODCALLTYPE RegisterProtocolHandler(HWND hwndParent, PSTR pszAppBuf, UINT ucAppBufLen);
  44. public:
  45. InternetShortcut(void);
  46. ~InternetShortcut(void);
  47. // IDataObject methods
  48. HRESULT STDMETHODCALLTYPE GetData(PFORMATETC pfmtetcIn, PSTGMEDIUM pstgmed);
  49. HRESULT STDMETHODCALLTYPE GetDataHere(PFORMATETC pfmtetc, PSTGMEDIUM pstgpmed);
  50. HRESULT STDMETHODCALLTYPE QueryGetData(PFORMATETC pfmtetc);
  51. HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(PFORMATETC pfmtetcIn, PFORMATETC pfmtetcOut);
  52. HRESULT STDMETHODCALLTYPE SetData(PFORMATETC pfmtetc, PSTGMEDIUM pstgmed, BOOL bRelease);
  53. HRESULT STDMETHODCALLTYPE EnumFormatEtc(DWORD dwDirection, PIEnumFORMATETC *ppienumFormatEtc);
  54. HRESULT STDMETHODCALLTYPE DAdvise(PFORMATETC pfmtetc, DWORD dwAdviseFlags, PIAdviseSink piadvsink, PDWORD pdwConnection);
  55. HRESULT STDMETHODCALLTYPE DUnadvise(DWORD dwConnection);
  56. HRESULT STDMETHODCALLTYPE EnumDAdvise(PIEnumSTATDATA *ppienumStatData);
  57. // IExtractIcon methods
  58. HRESULT STDMETHODCALLTYPE GetIconLocation(UINT uFlags, PSTR pszIconFile, UINT ucchMax, PINT pniIcon, PUINT puFlags);
  59. HRESULT STDMETHODCALLTYPE Extract(PCSTR pcszFile, UINT uIconIndex, PHICON phiconLarge, PHICON phiconSmall, UINT ucIconSize);
  60. // INewShortcutHook methods
  61. HRESULT STDMETHODCALLTYPE SetReferent(PCSTR pcszReferent, HWND hwndParent);
  62. HRESULT STDMETHODCALLTYPE GetReferent(PSTR pszReferent, int ncReferentBufLen);
  63. HRESULT STDMETHODCALLTYPE SetFolder(PCSTR pcszFolder);
  64. HRESULT STDMETHODCALLTYPE GetFolder(PSTR pszFolder, int ncFolderBufLen);
  65. HRESULT STDMETHODCALLTYPE GetName(PSTR pszName, int ncNameBufLen);
  66. HRESULT STDMETHODCALLTYPE GetExtension(PSTR pszExtension, int ncExtensionBufLen);
  67. // IPersist methods
  68. HRESULT STDMETHODCALLTYPE GetClassID(PCLSID pclsid);
  69. // IPersistFile methods
  70. HRESULT STDMETHODCALLTYPE IsDirty(void);
  71. HRESULT STDMETHODCALLTYPE Save(LPCOLESTR pcwszFileName, BOOL bRemember);
  72. HRESULT STDMETHODCALLTYPE SaveCompleted(LPCOLESTR pcwszFileName);
  73. HRESULT STDMETHODCALLTYPE Load(LPCOLESTR pcwszFileName, DWORD dwMode);
  74. HRESULT STDMETHODCALLTYPE GetCurFile(LPOLESTR *ppwszFileName);
  75. // IPersistStream methods
  76. HRESULT STDMETHODCALLTYPE Save(PIStream pistr, BOOL bClearDirty);
  77. HRESULT STDMETHODCALLTYPE Load(PIStream pistr);
  78. HRESULT STDMETHODCALLTYPE GetSizeMax(PULARGE_INTEGER pcbSize);
  79. // IShellExecuteHook methods
  80. HRESULT STDMETHODCALLTYPE Execute(PSHELLEXECUTEINFO pei);
  81. // IShellExtInit methods
  82. HRESULT STDMETHODCALLTYPE Initialize(PCITEMIDLIST pcidlFolder, PIDataObject pidobj, HKEY hkeyProgID);
  83. // IShellLink methods
  84. HRESULT STDMETHODCALLTYPE SetPath(PCSTR pcszPath);
  85. HRESULT STDMETHODCALLTYPE GetPath(PSTR pszFile, int ncFileBufLen, PWIN32_FIND_DATA pwfd, DWORD dwFlags);
  86. HRESULT STDMETHODCALLTYPE SetRelativePath(PCSTR pcszRelativePath, DWORD dwReserved);
  87. HRESULT STDMETHODCALLTYPE SetIDList(LPCITEMIDLIST pcidl);
  88. HRESULT STDMETHODCALLTYPE GetIDList(LPITEMIDLIST *ppidl);
  89. HRESULT STDMETHODCALLTYPE SetDescription(PCSTR pcszDescription);
  90. HRESULT STDMETHODCALLTYPE GetDescription(PSTR pszDescription, int ncDesciptionBufLen);
  91. HRESULT STDMETHODCALLTYPE SetArguments(PCSTR pcszArgs);
  92. HRESULT STDMETHODCALLTYPE GetArguments(PSTR pszArgs, int ncArgsBufLen);
  93. HRESULT STDMETHODCALLTYPE SetWorkingDirectory(PCSTR pcszWorkingDirectory);
  94. HRESULT STDMETHODCALLTYPE GetWorkingDirectory(PSTR pszWorkingDirectory, int ncbLen);
  95. HRESULT STDMETHODCALLTYPE SetHotkey(WORD wHotkey);
  96. HRESULT STDMETHODCALLTYPE GetHotkey(PWORD pwHotkey);
  97. HRESULT STDMETHODCALLTYPE SetShowCmd(int nShowCmd);
  98. HRESULT STDMETHODCALLTYPE GetShowCmd(PINT pnShowCmd);
  99. HRESULT STDMETHODCALLTYPE SetIconLocation(PCSTR pcszIconFile, int niIcon);
  100. HRESULT STDMETHODCALLTYPE GetIconLocation(PSTR pszIconFile, int ncbLen, PINT pniIcon);
  101. HRESULT STDMETHODCALLTYPE Resolve(HWND hwnd, DWORD dwFlags);
  102. // IShellPropSheetExt methods
  103. HRESULT STDMETHODCALLTYPE AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam);
  104. HRESULT STDMETHODCALLTYPE ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplaceWith, LPARAM lParam);
  105. // IUniformResourceLocator methods
  106. HRESULT STDMETHODCALLTYPE SetURL(PCSTR pcszURL, DWORD dwFlags);
  107. HRESULT STDMETHODCALLTYPE GetURL(PSTR *ppszURL);
  108. HRESULT STDMETHODCALLTYPE InvokeCommand(PURLINVOKECOMMANDINFO purlici);
  109. // IUnknown methods
  110. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, PVOID *ppvObj);
  111. ULONG STDMETHODCALLTYPE AddRef(void);
  112. ULONG STDMETHODCALLTYPE Release(void);
  113. // other methods
  114. HRESULT STDMETHODCALLTYPE SaveToFile(PCSTR pcszFile, BOOL bRemember);
  115. HRESULT STDMETHODCALLTYPE LoadFromFile(PCSTR pcszFile, BOOL bRemember);
  116. HRESULT STDMETHODCALLTYPE GetCurFile(PSTR pszFile, UINT ucbLen);
  117. HRESULT STDMETHODCALLTYPE Dirty(BOOL bDirty);
  118. #ifdef DEBUG
  119. void STDMETHODCALLTYPE Dump(void);
  120. #endif
  121. // friends
  122. #ifdef DEBUG
  123. friend BOOL IsValidPCInternetShortcut(const InternetShortcut *pcintshcut);
  124. #endif
  125. };
  126. DECLARE_STANDARD_TYPES(InternetShortcut);
  127. /* Global Constants
  128. *******************/
  129. // intshcut.cpp
  130. extern const int g_nDefaultShowCmd;
  131. /* Prototypes
  132. *************/
  133. // intshcut.cpp
  134. extern HRESULT IsProtocolRegistered(PCSTR pcszProtocol);
  135. extern HRESULT ValidateURL(PCSTR pcszURL);
  136. extern HRESULT ValidateWorkingDirectory(PCSTR pcszWorkingDirectory);