ReactOS  0.4.14-dev-1034-g1e60116
CShellLink.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 1997 Marcus Meissner
4  * Copyright 1998 Juergen Schmied
5  * Copyright 2005 Mike McCormack
6  * Copyright 2009 Andrew Hill
7  * Copyright 2017 Hermes Belusca-Maito
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  *
23  */
24 
25 #ifndef _SHELLLINK_H_
26 #define _SHELLLINK_H_
27 
28 class CShellLink :
29  public CComCoClass<CShellLink, &CLSID_ShellLink>,
30  public CComObjectRootEx<CComMultiThreadModelNoCS>,
31  public IShellLinkA,
32  public IShellLinkW,
33  public IPersistStream,
34  public IPersistFile,
35  public IShellExtInit,
36  public IContextMenu, // Technically it should be IContextMenu3 (inherits from IContextMenu2 and IContextMenu)
37  public IDropTarget,
38 // public IQueryInfo,
39  public IShellLinkDataList,
40  public IExtractIconA,
41  public IExtractIconW,
42 // public IExtractImage2, // Inherits from IExtractImage
43 // public IPersistPropertyBag,
44 // public IServiceProvider,
45 // public IFilter,
46  public IObjectWithSite,
47 // public ICustomizeInfoTip,
48  public IShellPropSheetExt
49 {
50 public:
51  /* Link file formats */
52 
53  #include "pshpack1.h"
54  struct volume_info
55  {
58  WCHAR label[12]; /* assume 8.3 */
59  };
60  #include "poppack.h"
61 
62  enum IDCMD
63  {
66  };
67 
68 private:
69  /* Cached link header */
71 
72  /* Cached data set according to m_Header.dwFlags (SHELL_LINK_DATA_FLAGS) */
73 
75 
76  /* Link tracker information */
79 
87  LPDBLIST m_pDBList; /* Optional data block list (in the extra data section) */
88  BOOL m_bInInit; // in initialization or not
91 
92  /* Pointers to strings inside Logo3/Darwin info blocks, cached for debug info purposes only */
95 
97 
98  CComPtr<IUnknown> m_site;
99  CComPtr<IDropTarget> m_DropTarget;
100 
101  VOID Reset();
102 
105  HRESULT WriteAdvertiseInfo(LPCWSTR string, DWORD dwSig);
108 
111 
112 public:
113  CShellLink();
114  ~CShellLink();
116 
117  BOOL OnInitDialog(HWND hwndDlg, HWND hwndFocus, LPARAM lParam);
118  void OnCommand(HWND hwndDlg, int id, HWND hwndCtl, UINT codeNotify);
119  LRESULT OnNotify(HWND hwndDlg, int idFrom, LPNMHDR pnmhdr);
120  void OnDestroy(HWND hwndDlg);
121 
122  // IPersistFile
123  virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pclsid);
125  virtual HRESULT STDMETHODCALLTYPE Load(LPCOLESTR pszFileName, DWORD dwMode);
126  virtual HRESULT STDMETHODCALLTYPE Save(LPCOLESTR pszFileName, BOOL fRemember);
128  virtual HRESULT STDMETHODCALLTYPE GetCurFile(LPOLESTR *ppszFileName);
129 
130  // IPersistStream
131  // virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID *pclsid);
132  // virtual HRESULT STDMETHODCALLTYPE IsDirty();
133  virtual HRESULT STDMETHODCALLTYPE Load(IStream *stm);
134  virtual HRESULT STDMETHODCALLTYPE Save(IStream *stm, BOOL fClearDirty);
136 
137  // IShellLinkA
138  virtual HRESULT STDMETHODCALLTYPE GetPath(LPSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags);
141  virtual HRESULT STDMETHODCALLTYPE GetDescription(LPSTR pszName, INT cchMaxName);
145  virtual HRESULT STDMETHODCALLTYPE GetArguments(LPSTR pszArgs, INT cchMaxPath);
146  virtual HRESULT STDMETHODCALLTYPE SetArguments(LPCSTR pszArgs);
147  virtual HRESULT STDMETHODCALLTYPE GetHotkey(WORD *pwHotkey);
148  virtual HRESULT STDMETHODCALLTYPE SetHotkey(WORD wHotkey);
149  virtual HRESULT STDMETHODCALLTYPE GetShowCmd(INT *piShowCmd);
150  virtual HRESULT STDMETHODCALLTYPE SetShowCmd(INT iShowCmd);
151  virtual HRESULT STDMETHODCALLTYPE GetIconLocation(LPSTR pszIconPath, INT cchIconPath, INT *piIcon);
152  virtual HRESULT STDMETHODCALLTYPE SetIconLocation(LPCSTR pszIconPath, INT iIcon);
154  virtual HRESULT STDMETHODCALLTYPE Resolve(HWND hwnd, DWORD fFlags);
155  virtual HRESULT STDMETHODCALLTYPE SetPath(LPCSTR pszFile);
156 
157  // IShellLinkW
158  virtual HRESULT STDMETHODCALLTYPE GetPath(LPWSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags);
159  // virtual HRESULT STDMETHODCALLTYPE GetIDList(PIDLIST_ABSOLUTE *ppidl);
160  // virtual HRESULT STDMETHODCALLTYPE SetIDList(PCIDLIST_ABSOLUTE pidl);
161  virtual HRESULT STDMETHODCALLTYPE GetDescription(LPWSTR pszName, INT cchMaxName);
165  virtual HRESULT STDMETHODCALLTYPE GetArguments(LPWSTR pszArgs, INT cchMaxPath);
167  // virtual HRESULT STDMETHODCALLTYPE GetHotkey(WORD *pwHotkey);
168  // virtual HRESULT STDMETHODCALLTYPE SetHotkey(WORD wHotkey);
169  // virtual HRESULT STDMETHODCALLTYPE GetShowCmd(INT *piShowCmd);
170  // virtual HRESULT STDMETHODCALLTYPE SetShowCmd(INT iShowCmd);
171  virtual HRESULT STDMETHODCALLTYPE GetIconLocation(LPWSTR pszIconPath, INT cchIconPath, INT *piIcon);
172  virtual HRESULT STDMETHODCALLTYPE SetIconLocation(LPCWSTR pszIconPath, INT iIcon);
174  // virtual HRESULT STDMETHODCALLTYPE Resolve(HWND hwnd, DWORD fFlags);
175  virtual HRESULT STDMETHODCALLTYPE SetPath(LPCWSTR pszFile);
176 
177  // IShellLinkDataList
178  virtual HRESULT STDMETHODCALLTYPE AddDataBlock(void *pDataBlock);
179  virtual HRESULT STDMETHODCALLTYPE CopyDataBlock(DWORD dwSig, void **ppDataBlock);
181  virtual HRESULT STDMETHODCALLTYPE GetFlags(DWORD *pdwFlags);
183 
184  // IExtractIconA
185  virtual HRESULT STDMETHODCALLTYPE Extract(PCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
186  virtual HRESULT STDMETHODCALLTYPE GetIconLocation(UINT uFlags, PSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags);
187 
188  // IExtractIconW
189  virtual HRESULT STDMETHODCALLTYPE Extract(PCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
190  virtual HRESULT STDMETHODCALLTYPE GetIconLocation(UINT uFlags, PWSTR pszIconFile, UINT cchMax, int *piIndex, UINT *pwFlags);
191 
192  // IShellExtInit
193  virtual HRESULT STDMETHODCALLTYPE Initialize(PCIDLIST_ABSOLUTE pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID);
194 
195  // IContextMenu
196  virtual HRESULT STDMETHODCALLTYPE QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
198  virtual HRESULT STDMETHODCALLTYPE GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
199 
200  // IShellPropSheetExt
202  virtual HRESULT STDMETHODCALLTYPE ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam);
203 
204  // IObjectWithSite
205  virtual HRESULT STDMETHODCALLTYPE SetSite(IUnknown *punk);
206  virtual HRESULT STDMETHODCALLTYPE GetSite(REFIID iid, void **ppvSite);
207 
208  // IDropTarget
209  virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect);
210  virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD dwKeyState, POINTL pt, DWORD *pdwEffect);
212  virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect);
213 
216 
218 
220  COM_INTERFACE_ENTRY_IID(IID_IShellLinkA, IShellLinkA)
221  COM_INTERFACE_ENTRY_IID(IID_IShellLinkW, IShellLinkW)
225  COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit)
226  COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu) // Technically it should be IContextMenu3
227  COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
228 // COM_INTERFACE_ENTRY_IID(IID_IQueryInfo, IQueryInfo)
229  COM_INTERFACE_ENTRY_IID(IID_IShellLinkDataList, IShellLinkDataList)
230  COM_INTERFACE_ENTRY_IID(IID_IExtractIconA, IExtractIconA)
231  COM_INTERFACE_ENTRY_IID(IID_IExtractIconW, IExtractIconW)
232 // COM_INTERFACE_ENTRY_IID(IID_IExtractImage2, IExtractImage2)
233 // COM_INTERFACE_ENTRY_IID(IID_IPersistPropertyBag, IPersistPropertyBag)
234 // COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
235 // COM_INTERFACE_ENTRY_IID(IID_IFilter, IFilter)
237 // COM_INTERFACE_ENTRY_IID(IID_ICustomizeInfoTip, ICustomizeInfoTip)
238  COM_INTERFACE_ENTRY_IID(IID_IShellPropSheetExt, IShellPropSheetExt)
239 END_COM_MAP()
240 };
241 
242 #endif /* _SHELLLINK_H_ */
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
const uint16_t * PCWSTR
Definition: typedefs.h:56
static HICON
Definition: imagelist.c:84
#define REFIID
Definition: guiddef.h:118
#define IDR_SHELLLINK
Definition: shresdef.h:816
static HMENU hmenu
Definition: win.c:66
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define pt(x, y)
Definition: drawing.c:79
uint16_t * PWSTR
Definition: typedefs.h:55
const GUID IID_IPersist
Definition: proxy.cpp:14
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define CALLBACK
Definition: compat.h:27
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:611
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:327
UINT_PTR WPARAM
Definition: windef.h:207
UINT uFlags
Definition: api.c:59
int32_t INT_PTR
Definition: typedefs.h:63
char * LPSTR
Definition: xmlstorage.h:182
static LPOLESTR
Definition: stg_prop.c:27
int32_t INT
Definition: typedefs.h:57
WPARAM wParam
Definition: combotst.c:138
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
Definition: mswsock.h:90
unsigned int BOOL
Definition: ntddk_ex.h:94
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
const char * LPCSTR
Definition: xmlstorage.h:183
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:541
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:78
_In_ LPCSTR pszDir
Definition: shellapi.h:580
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
const IID IID_IObjectWithSite
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define COM_INTERFACE_ENTRY2_IID(iid, x, x2)
Definition: atlcom.h:569
UINT cchMax
const GUID IID_IPersistStream
Definition: proxy.cpp:13
static const WCHAR IconIndex[]
Definition: install.c:52
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define DECLARE_REGISTRY_RESOURCEID(x)
Definition: atlcom.h:605
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:561
signed char * PSTR
Definition: retypes.h:7
unsigned int UINT
Definition: ndis.h:50
#define DECLARE_PROTECT_FINAL_CONSTRUCT()
Definition: atlcom.h:639
const GUID IID_IPersistFile
const char * PCSTR
Definition: typedefs.h:52
#define END_COM_MAP()
Definition: atlcom.h:552
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
LPARAM lParam
Definition: combotst.c:139