[SHELL32]
[reactos.git] / dll / win32 / shell32 / CShellLink.h
1 /*
2 *
3 * Copyright 1997 Marcus Meissner
4 * Copyright 1998 Juergen Schmied
5 * Copyright 2005 Mike McCormack
6 * Copyright 2009 Andrew Hill
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 *
22 */
23
24 #ifndef _SHELLLINK_H_
25 #define _SHELLLINK_H_
26
27 class CShellLink :
28 public CComCoClass<CShellLink, &CLSID_ShellLink>,
29 public CComObjectRootEx<CComMultiThreadModelNoCS>,
30 public IShellLinkA,
31 public IShellLinkW,
32 public IPersistFile,
33 public IPersistStream,
34 public IShellLinkDataList,
35 public IShellExtInit,
36 public IContextMenu,
37 public IDropTarget,
38 public IObjectWithSite,
39 public IShellPropSheetExt
40 {
41 public:
42 /* link file formats */
43
44 #include "pshpack1.h"
45
46 struct volume_info
47 {
48 DWORD type;
49 DWORD serial;
50 WCHAR label[12]; /* assume 8.3 */
51 };
52
53 #include "poppack.h"
54
55 private:
56 /* data structures according to the information in the link */
57 LPITEMIDLIST pPidl;
58 WORD wHotKey;
59 SYSTEMTIME time1;
60 SYSTEMTIME time2;
61 SYSTEMTIME time3;
62
63 DWORD iShowCmd;
64 LPWSTR sIcoPath;
65 INT iIcoNdx;
66 LPWSTR sPath;
67 LPWSTR sArgs;
68 LPWSTR sWorkDir;
69 LPWSTR sDescription;
70 LPWSTR sPathRel;
71 LPWSTR sProduct;
72 LPWSTR sComponent;
73 volume_info volume;
74 LPWSTR sLinkPath;
75 BOOL bRunAs;
76 BOOL bDirty;
77 INT iIdOpen; /* id of the "Open" entry in the context menu */
78 CComPtr<IUnknown> site;
79 CComPtr<IDropTarget> mDropTarget;
80 public:
81 CShellLink();
82 ~CShellLink();
83 LPWSTR ShellLink_GetAdvertisedArg(LPCWSTR str);
84 HRESULT ShellLink_SetAdvertiseInfo(LPCWSTR str);
85 static INT_PTR CALLBACK SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
86
87 // IPersistFile
88 virtual HRESULT WINAPI GetClassID(CLSID *pclsid);
89 virtual HRESULT WINAPI IsDirty();
90 virtual HRESULT WINAPI Load(LPCOLESTR pszFileName, DWORD dwMode);
91 virtual HRESULT WINAPI Save(LPCOLESTR pszFileName, BOOL fRemember);
92 virtual HRESULT WINAPI SaveCompleted(LPCOLESTR pszFileName);
93 virtual HRESULT WINAPI GetCurFile(LPOLESTR *ppszFileName);
94
95 // IPersistStream
96 // virtual WINAPI HRESULT GetClassID(CLSID *pclsid);
97 // virtual HRESULT WINAPI IsDirty();
98 virtual HRESULT WINAPI Load(IStream *stm);
99 virtual HRESULT WINAPI Save(IStream *stm, BOOL fClearDirty);
100 virtual HRESULT WINAPI GetSizeMax(ULARGE_INTEGER *pcbSize);
101
102 // IShellLinkA
103 virtual HRESULT WINAPI GetPath(LPSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAA *pfd, DWORD fFlags);
104 virtual HRESULT WINAPI GetIDList(LPITEMIDLIST * ppidl);
105 virtual HRESULT WINAPI SetIDList(LPCITEMIDLIST pidl);
106 virtual HRESULT WINAPI GetDescription(LPSTR pszName,INT cchMaxName);
107 virtual HRESULT WINAPI SetDescription(LPCSTR pszName);
108 virtual HRESULT WINAPI GetWorkingDirectory(LPSTR pszDir,INT cchMaxPath);
109 virtual HRESULT WINAPI SetWorkingDirectory(LPCSTR pszDir);
110 virtual HRESULT WINAPI GetArguments(LPSTR pszArgs,INT cchMaxPath);
111 virtual HRESULT WINAPI SetArguments(LPCSTR pszArgs);
112 virtual HRESULT WINAPI GetHotkey(WORD *pwHotkey);
113 virtual HRESULT WINAPI SetHotkey(WORD wHotkey);
114 virtual HRESULT WINAPI GetShowCmd(INT *piShowCmd);
115 virtual HRESULT WINAPI SetShowCmd(INT iShowCmd);
116 virtual HRESULT WINAPI GetIconLocation(LPSTR pszIconPath,INT cchIconPath,INT *piIcon);
117 virtual HRESULT WINAPI SetIconLocation(LPCSTR pszIconPath,INT iIcon);
118 virtual HRESULT WINAPI SetRelativePath(LPCSTR pszPathRel, DWORD dwReserved);
119 virtual HRESULT WINAPI Resolve(HWND hwnd, DWORD fFlags);
120 virtual HRESULT WINAPI SetPath(LPCSTR pszFile);
121
122 // IShellLinkW
123 virtual HRESULT WINAPI GetPath(LPWSTR pszFile, INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags);
124 // virtual HRESULT WINAPI GetIDList(LPITEMIDLIST *ppidl);
125 // virtual HRESULT WINAPI SetIDList(LPCITEMIDLIST pidl);
126 virtual HRESULT WINAPI GetDescription(LPWSTR pszName, INT cchMaxName);
127 virtual HRESULT WINAPI SetDescription(LPCWSTR pszName);
128 virtual HRESULT WINAPI GetWorkingDirectory(LPWSTR pszDir, INT cchMaxPath);
129 virtual HRESULT WINAPI SetWorkingDirectory(LPCWSTR pszDir);
130 virtual HRESULT WINAPI GetArguments(LPWSTR pszArgs,INT cchMaxPath);
131 virtual HRESULT WINAPI SetArguments(LPCWSTR pszArgs);
132 // virtual HRESULT WINAPI GetHotkey(WORD *pwHotkey);
133 // virtual HRESULT WINAPI SetHotkey(WORD wHotkey);
134 // virtual HRESULT WINAPI GetShowCmd(INT *piShowCmd);
135 // virtual HRESULT WINAPI SetShowCmd(INT iShowCmd);
136 virtual HRESULT WINAPI GetIconLocation(LPWSTR pszIconPath,INT cchIconPath,INT *piIcon);
137 virtual HRESULT WINAPI SetIconLocation(LPCWSTR pszIconPath,INT iIcon);
138 virtual HRESULT WINAPI SetRelativePath(LPCWSTR pszPathRel, DWORD dwReserved);
139 // virtual HRESULT WINAPI Resolve(HWND hwnd, DWORD fFlags);
140 virtual HRESULT WINAPI SetPath(LPCWSTR pszFile);
141
142 // IShellLinkDataList
143 virtual HRESULT WINAPI AddDataBlock(void *pDataBlock);
144 virtual HRESULT WINAPI CopyDataBlock(DWORD dwSig, void **ppDataBlock);
145 virtual HRESULT WINAPI RemoveDataBlock(DWORD dwSig);
146 virtual HRESULT WINAPI GetFlags(DWORD *pdwFlags);
147 virtual HRESULT WINAPI SetFlags(DWORD dwFlags);
148
149 // IShellExtInit
150 virtual HRESULT WINAPI Initialize(LPCITEMIDLIST pidlFolder, IDataObject *pdtobj, HKEY hkeyProgID);
151
152 // IContextMenu
153 virtual HRESULT WINAPI QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
154 virtual HRESULT WINAPI InvokeCommand(LPCMINVOKECOMMANDINFO lpici);
155 virtual HRESULT WINAPI GetCommandString(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);
156
157 // IShellPropSheetExt
158 virtual HRESULT WINAPI AddPages(LPFNADDPROPSHEETPAGE pfnAddPage, LPARAM lParam);
159 virtual HRESULT WINAPI ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE pfnReplacePage, LPARAM lParam);
160
161 // IObjectWithSite
162 virtual HRESULT WINAPI SetSite(IUnknown *punk);
163 virtual HRESULT WINAPI GetSite(REFIID iid, void **ppvSite);
164
165 // IDropTarget
166 virtual HRESULT WINAPI DragEnter(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect);
167 virtual HRESULT WINAPI DragOver(DWORD dwKeyState, POINTL pt, DWORD *pdwEffect);
168 virtual HRESULT WINAPI DragLeave();
169 virtual HRESULT WINAPI Drop(IDataObject *pDataObject, DWORD dwKeyState, POINTL pt, DWORD *pdwEffect);
170
171 DECLARE_REGISTRY_RESOURCEID(IDR_SHELLLINK)
172 DECLARE_NOT_AGGREGATABLE(CShellLink)
173
174 DECLARE_PROTECT_FINAL_CONSTRUCT()
175
176 BEGIN_COM_MAP(CShellLink)
177 COM_INTERFACE_ENTRY2_IID(IID_IPersist, IPersist, IPersistFile)
178 COM_INTERFACE_ENTRY_IID(IID_IPersistFile, IPersistFile)
179 COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
180 COM_INTERFACE_ENTRY_IID(IID_IShellLinkA, IShellLinkA)
181 COM_INTERFACE_ENTRY_IID(IID_IShellLinkW, IShellLinkW)
182 COM_INTERFACE_ENTRY_IID(IID_IShellLinkDataList, IShellLinkDataList)
183 COM_INTERFACE_ENTRY_IID(IID_IShellExtInit, IShellExtInit)
184 COM_INTERFACE_ENTRY_IID(IID_IContextMenu, IContextMenu)
185 COM_INTERFACE_ENTRY_IID(IID_IDropTarget, IDropTarget)
186 COM_INTERFACE_ENTRY_IID(IID_IShellPropSheetExt, IShellPropSheetExt)
187 COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
188 END_COM_MAP()
189 };
190
191 #endif /* _SHELLLINK_H_ */