1c2c66affSColin Finck /* 2c2c66affSColin Finck * 3c2c66affSColin Finck * Copyright 1997 Marcus Meissner 4c2c66affSColin Finck * Copyright 1998 Juergen Schmied 5c2c66affSColin Finck * Copyright 2005 Mike McCormack 6c2c66affSColin Finck * Copyright 2009 Andrew Hill 7c2c66affSColin Finck * Copyright 2017 Hermes Belusca-Maito 8c2c66affSColin Finck * 9c2c66affSColin Finck * This library is free software; you can redistribute it and/or 10c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public 11c2c66affSColin Finck * License as published by the Free Software Foundation; either 12c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version. 13c2c66affSColin Finck * 14c2c66affSColin Finck * This library is distributed in the hope that it will be useful, 15c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of 16c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17c2c66affSColin Finck * Lesser General Public License for more details. 18c2c66affSColin Finck * 19c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public 20c2c66affSColin Finck * License along with this library; if not, write to the Free Software 21c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 22c2c66affSColin Finck * 23c2c66affSColin Finck */ 24c2c66affSColin Finck 25c2c66affSColin Finck #ifndef _SHELLLINK_H_ 26c2c66affSColin Finck #define _SHELLLINK_H_ 27c2c66affSColin Finck 28c2c66affSColin Finck class CShellLink : 29c2c66affSColin Finck public CComCoClass<CShellLink, &CLSID_ShellLink>, 30c2c66affSColin Finck public CComObjectRootEx<CComMultiThreadModelNoCS>, 31c2c66affSColin Finck public IShellLinkA, 32c2c66affSColin Finck public IShellLinkW, 33c2c66affSColin Finck public IPersistStream, 34c2c66affSColin Finck public IPersistFile, 35c2c66affSColin Finck public IShellExtInit, 36c2c66affSColin Finck public IContextMenu, // Technically it should be IContextMenu3 (inherits from IContextMenu2 and IContextMenu) 37c2c66affSColin Finck public IDropTarget, 38c2c66affSColin Finck // public IQueryInfo, 39c2c66affSColin Finck public IShellLinkDataList, 40c2c66affSColin Finck public IExtractIconA, 41c2c66affSColin Finck public IExtractIconW, 42c2c66affSColin Finck // public IExtractImage2, // Inherits from IExtractImage 43c2c66affSColin Finck // public IPersistPropertyBag, 44c2c66affSColin Finck // public IServiceProvider, 45c2c66affSColin Finck // public IFilter, 46c2c66affSColin Finck public IObjectWithSite, 47c2c66affSColin Finck // public ICustomizeInfoTip, 48c2c66affSColin Finck public IShellPropSheetExt 49c2c66affSColin Finck { 50c2c66affSColin Finck public: 51c2c66affSColin Finck /* Link file formats */ 52c2c66affSColin Finck 53c2c66affSColin Finck #include "pshpack1.h" 54c2c66affSColin Finck struct volume_info 55c2c66affSColin Finck { 56c2c66affSColin Finck DWORD type; 57c2c66affSColin Finck DWORD serial; 58c2c66affSColin Finck WCHAR label[12]; /* assume 8.3 */ 59c2c66affSColin Finck }; 60c2c66affSColin Finck #include "poppack.h" 61c2c66affSColin Finck 62c0f340bcSKatayama Hirofumi MZ enum IDCMD 63c0f340bcSKatayama Hirofumi MZ { 64c0f340bcSKatayama Hirofumi MZ IDCMD_OPEN = 0, 65c0f340bcSKatayama Hirofumi MZ IDCMD_OPENFILELOCATION 66c0f340bcSKatayama Hirofumi MZ }; 67c0f340bcSKatayama Hirofumi MZ 68c2c66affSColin Finck private: 69c2c66affSColin Finck /* Cached link header */ 70c2c66affSColin Finck SHELL_LINK_HEADER m_Header; 71c2c66affSColin Finck 72c2c66affSColin Finck /* Cached data set according to m_Header.dwFlags (SHELL_LINK_DATA_FLAGS) */ 73c2c66affSColin Finck 74c2c66affSColin Finck LPITEMIDLIST m_pPidl; 75c2c66affSColin Finck 76c2c66affSColin Finck /* Link tracker information */ 77c2c66affSColin Finck LPWSTR m_sPath; 78c2c66affSColin Finck volume_info volume; 79c2c66affSColin Finck 80c2c66affSColin Finck LPWSTR m_sDescription; 81c2c66affSColin Finck LPWSTR m_sPathRel; 82c2c66affSColin Finck LPWSTR m_sWorkDir; 83c2c66affSColin Finck LPWSTR m_sArgs; 84c2c66affSColin Finck LPWSTR m_sIcoPath; 85c2c66affSColin Finck BOOL m_bRunAs; 86c2c66affSColin Finck BOOL m_bDirty; 87c2c66affSColin Finck LPDBLIST m_pDBList; /* Optional data block list (in the extra data section) */ 8896c0ef42SKatayama Hirofumi MZ BOOL m_bInInit; // in initialization or not 8996c0ef42SKatayama Hirofumi MZ HICON m_hIcon; 90c0f340bcSKatayama Hirofumi MZ UINT m_idCmdFirst; 91c2c66affSColin Finck 92c2c66affSColin Finck /* Pointers to strings inside Logo3/Darwin info blocks, cached for debug info purposes only */ 93c2c66affSColin Finck LPWSTR sProduct; 94c2c66affSColin Finck LPWSTR sComponent; 95c2c66affSColin Finck 96c2c66affSColin Finck LPWSTR m_sLinkPath; 97c2c66affSColin Finck 98c2c66affSColin Finck CComPtr<IUnknown> m_site; 99c2c66affSColin Finck CComPtr<IDropTarget> m_DropTarget; 100c2c66affSColin Finck 101c2c66affSColin Finck VOID Reset(); 102c2c66affSColin Finck 103c2c66affSColin Finck HRESULT GetAdvertiseInfo(LPWSTR *str, DWORD dwSig); 104c2c66affSColin Finck HRESULT SetAdvertiseInfo(LPCWSTR str); 105c2c66affSColin Finck HRESULT WriteAdvertiseInfo(LPCWSTR string, DWORD dwSig); 106c2c66affSColin Finck HRESULT SetTargetFromPIDLOrPath(LPCITEMIDLIST pidl, LPCWSTR pszFile); 10796c0ef42SKatayama Hirofumi MZ HICON CreateShortcutIcon(LPCWSTR wszIconPath, INT IconIndex); 108c2c66affSColin Finck 109c0f340bcSKatayama Hirofumi MZ HRESULT DoOpen(LPCMINVOKECOMMANDINFO lpici); 110c0f340bcSKatayama Hirofumi MZ HRESULT DoOpenFileLocation(); 111c0f340bcSKatayama Hirofumi MZ 112c2c66affSColin Finck public: 113c2c66affSColin Finck CShellLink(); 114c2c66affSColin Finck ~CShellLink(); 115c2c66affSColin Finck static INT_PTR CALLBACK SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 116c2c66affSColin Finck 11796c0ef42SKatayama Hirofumi MZ BOOL OnInitDialog(HWND hwndDlg, HWND hwndFocus, LPARAM lParam); 11896c0ef42SKatayama Hirofumi MZ void OnCommand(HWND hwndDlg, int id, HWND hwndCtl, UINT codeNotify); 11996c0ef42SKatayama Hirofumi MZ LRESULT OnNotify(HWND hwndDlg, int idFrom, LPNMHDR pnmhdr); 12096c0ef42SKatayama Hirofumi MZ void OnDestroy(HWND hwndDlg); 12196c0ef42SKatayama Hirofumi MZ 122c2c66affSColin Finck // IPersistFile 123*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetClassID)(CLSID *pclsid) override; 124*49b2b1daSKatayama Hirofumi MZ STDMETHOD(IsDirty)() override; 125*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Load)(LPCOLESTR pszFileName, DWORD dwMode) override; 126*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Save)(LPCOLESTR pszFileName, BOOL fRemember) override; 127*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SaveCompleted)(LPCOLESTR pszFileName) override; 128*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetCurFile)(LPOLESTR *ppszFileName) override; 129c2c66affSColin Finck 130c2c66affSColin Finck // IPersistStream 131*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(GetClassID)(CLSID *pclsid) override; 132*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(IsDirty)() override; 133*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Load)(IStream *stm) override; 134*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Save)(IStream *stm, BOOL fClearDirty) override; 135*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize) override; 136c2c66affSColin Finck 137c2c66affSColin Finck // IShellLinkA 138*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetPath)(LPSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags) override; 139*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetIDList)(PIDLIST_ABSOLUTE *ppidl) override; 140*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetIDList)(PCIDLIST_ABSOLUTE pidl) override; 141*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetDescription)(LPSTR pszName, INT cchMaxName) override; 142*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetDescription)(LPCSTR pszName) override; 143*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetWorkingDirectory)(LPSTR pszDir, INT cchMaxPath) override; 144*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetWorkingDirectory)(LPCSTR pszDir) override; 145*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetArguments)(LPSTR pszArgs, INT cchMaxPath) override; 146*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetArguments)(LPCSTR pszArgs) override; 147*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetHotkey)(WORD *pwHotkey) override; 148*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetHotkey)(WORD wHotkey) override; 149*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetShowCmd)(INT *piShowCmd) override; 150*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetShowCmd)(INT iShowCmd) override; 151*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetIconLocation)(LPSTR pszIconPath, INT cchIconPath, INT *piIcon) override; 152*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetIconLocation)(LPCSTR pszIconPath, INT iIcon) override; 153*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetRelativePath)(LPCSTR pszPathRel, DWORD dwReserved) override; 154*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Resolve)(HWND hwnd, DWORD fFlags) override; 155*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetPath)(LPCSTR pszFile) override; 156c2c66affSColin Finck 157c2c66affSColin Finck // IShellLinkW 158*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetPath)(LPWSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags) override; 159*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(GetIDList)(PIDLIST_ABSOLUTE *ppidl) override; 160*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(SetIDList)(PCIDLIST_ABSOLUTE pidl) override; 161*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetDescription)(LPWSTR pszName, INT cchMaxName) override; 162*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetDescription)(LPCWSTR pszName) override; 163*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetWorkingDirectory)(LPWSTR pszDir, INT cchMaxPath) override; 164*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetWorkingDirectory)(LPCWSTR pszDir) override; 165*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetArguments)(LPWSTR pszArgs, INT cchMaxPath) override; 166*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetArguments)(LPCWSTR pszArgs) override; 167*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(GetHotkey)(WORD *pwHotkey) override; 168*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(SetHotkey)(WORD wHotkey) override; 169*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(GetShowCmd)(INT *piShowCmd) override; 170*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(SetShowCmd)(INT iShowCmd) override; 171*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetIconLocation)(LPWSTR pszIconPath, INT cchIconPath, INT *piIcon) override; 172*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetIconLocation)(LPCWSTR pszIconPath, INT iIcon) override; 173*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetRelativePath)(LPCWSTR pszPathRel, DWORD dwReserved) override; 174*49b2b1daSKatayama Hirofumi MZ // STDMETHOD(Resolve)(HWND hwnd, DWORD fFlags) override; 175*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetPath)(LPCWSTR pszFile) override; 176c2c66affSColin Finck 177c2c66affSColin Finck // IShellLinkDataList 178*49b2b1daSKatayama Hirofumi MZ STDMETHOD(AddDataBlock)(void *pDataBlock) override; 179*49b2b1daSKatayama Hirofumi MZ STDMETHOD(CopyDataBlock)(DWORD dwSig, void **ppDataBlock) override; 180*49b2b1daSKatayama Hirofumi MZ STDMETHOD(RemoveDataBlock)(DWORD dwSig) override; 181*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetFlags)(DWORD *pdwFlags) override; 182*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetFlags)(DWORD dwFlags) override; 183c2c66affSColin Finck 184c2c66affSColin Finck // IExtractIconA 185*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Extract)(PCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) override; 186*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetIconLocation)(UINT uFlags, PSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags) override; 187c2c66affSColin Finck 188c2c66affSColin Finck // IExtractIconW 189*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Extract)(PCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize) override; 190*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetIconLocation)(UINT uFlags, PWSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags) override; 191c2c66affSColin Finck 192c2c66affSColin Finck // IShellExtInit 193*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Initialize)(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID) override; 194c2c66affSColin Finck 195c2c66affSColin Finck // IContextMenu 196*49b2b1daSKatayama Hirofumi MZ STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) override; 197*49b2b1daSKatayama Hirofumi MZ STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici) override; 198*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax) override; 199c2c66affSColin Finck 200c2c66affSColin Finck // IShellPropSheetExt 201*49b2b1daSKatayama Hirofumi MZ STDMETHOD(AddPages)(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam) override; 202*49b2b1daSKatayama Hirofumi MZ STDMETHOD(ReplacePage)(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam) override; 203c2c66affSColin Finck 204c2c66affSColin Finck // IObjectWithSite 205*49b2b1daSKatayama Hirofumi MZ STDMETHOD(SetSite)(IUnknown *punk) override; 206*49b2b1daSKatayama Hirofumi MZ STDMETHOD(GetSite)(REFIID iid, void **ppvSite) override; 207c2c66affSColin Finck 208c2c66affSColin Finck // IDropTarget 209*49b2b1daSKatayama Hirofumi MZ STDMETHOD(DragEnter)(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override; 210*49b2b1daSKatayama Hirofumi MZ STDMETHOD(DragOver)(DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override; 211*49b2b1daSKatayama Hirofumi MZ STDMETHOD(DragLeave)() override; 212*49b2b1daSKatayama Hirofumi MZ STDMETHOD(Drop)(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect) override; 213c2c66affSColin Finck 214c2c66affSColin Finck DECLARE_REGISTRY_RESOURCEID(IDR_SHELLLINK) 215c2c66affSColin Finck DECLARE_NOT_AGGREGATABLE(CShellLink) 216c2c66affSColin Finck 217c2c66affSColin Finck DECLARE_PROTECT_FINAL_CONSTRUCT() 218c2c66affSColin Finck 219c2c66affSColin Finck BEGIN_COM_MAP(CShellLink) 220c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IShellLinkA, IShellLinkA) 221c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IShellLinkW, IShellLinkW) 222c2c66affSColin Finck COM_INTERFACE_ENTRY2_IID(IID_IPersist, IPersist, IPersistFile) 223c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IPersistFile, IPersistFile) 224c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream) 225c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit) 226c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) // Technically it should be IContextMenu3 227c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget) 228c2c66affSColin Finck // COM_INTERFACE_ENTRY_IID(IID_IQueryInfo, IQueryInfo) 229c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IShellLinkDataList, IShellLinkDataList) 230c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IExtractIconA, IExtractIconA) 231c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IExtractIconW, IExtractIconW) 232c2c66affSColin Finck // COM_INTERFACE_ENTRY_IID(IID_IExtractImage2, IExtractImage2) 233c2c66affSColin Finck // COM_INTERFACE_ENTRY_IID(IID_IPersistPropertyBag, IPersistPropertyBag) 234c2c66affSColin Finck // COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider) 235c2c66affSColin Finck // COM_INTERFACE_ENTRY_IID(IID_IFilter, IFilter) 236c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite) 237c2c66affSColin Finck // COM_INTERFACE_ENTRY_IID(IID_ICustomizeInfoTip, ICustomizeInfoTip) 238c2c66affSColin Finck COM_INTERFACE_ENTRY_IID(IID_IShellPropSheetExt, IShellPropSheetExt) 239c2c66affSColin Finck END_COM_MAP() 240c2c66affSColin Finck }; 241c2c66affSColin Finck 242c2c66affSColin Finck #endif /* _SHELLLINK_H_ */ 243