Reactos
1#ifndef _PRECOMP_H__
2#define _PRECOMP_H__
3
4#include <stdarg.h>
5#include <assert.h>
6
7#define COBJMACROS
8#define WIN32_NO_STATUS
9#define _INC_WINDOWS
10#define COM_NO_WINDOWS_H
11#define NTOS_MODE_USER
12
13#include <windef.h>
14#include <winbase.h>
15#include <winreg.h>
16#include <winuser.h>
17#include <wincon.h>
18#include <commdlg.h>
19#include <ddeml.h>
20#include <userenv.h>
21
22#include <shlwapi.h>
23#include <wininet.h>
24#include <shlobj.h>
25#include <shobjidl.h>
26#include <emptyvc.h>
27#include <ndk/rtlfuncs.h>
28#include <fmifs/fmifs.h>
29#include <tchar.h>
30#include <strsafe.h>
31#include <atlbase.h>
32#include <atlcom.h>
33#include <atlwin.h>
34#include <atlstr.h>
35#include <atlsimpcoll.h>
36#include <atlcoll.h>
37#include <powrprof.h>
38#include <winnetwk.h>
39#include <objsafe.h>
40#include <regstr.h>
41
42#include <comctl32_undoc.h>
43#include <shlguid_undoc.h>
44#include <shlobj_undoc.h>
45
46#include <shlwapi_undoc.h>
47#include <ishellfolder_helpers.h>
48
49#include <shellapi.h>
50#undef ShellExecute
51#include <undocshell.h>
52
53/*
54 * For versions < Vista+, redefine ShellMessageBoxW to ShellMessageBoxWrapW
55 * (this is needed to avoid a linker error). On Vista+ onwards, shell32.ShellMessageBoxW
56 * redirects to shlwapi.ShellMessageBoxW so the #define should not be needed.
57 *
58 * However our shell32 is built with _WIN32_WINNT set to 0x600 (Vista+),
59 * yet its exports (especially regarding ShellMessageBoxA/W) are Win2003
60 * compatible. So the #define is still needed, and the check be disabled.
61 */
62// #if (_WIN32_WINNT < 0x0600)
63#define ShellMessageBoxW ShellMessageBoxWrapW
64// #endif
65
66#include <browseui_undoc.h>
67
68#include <shellutils.h>
69
70#include "shellrecyclebin/recyclebin.h"
71#include "wine/pidl.h"
72#include "debughlp.h"
73#include "wine/shell32_main.h"
74#include "shresdef.h"
75#include "wine/cpanel.h"
76#include "CActiveDesktop.h"
77#include "CEnumIDListBase.h"
78#include "shfldr.h"
79#include "CShellItem.h"
80#include "CShellLink.h"
81#include "CFolderItemVerbs.h"
82#include "CFolderItems.h"
83#include "CFolder.h"
84#include "CShellDispatch.h"
85#include "CDropTargetHelper.h"
86#include "CFolderOptions.h"
87#include "folders/CFSFolder.h"
88#include "folders/CDrivesFolder.h"
89#include "folders/CDesktopFolder.h"
90#include "folders/CControlPanelFolder.h"
91#include "folders/CMyDocsFolder.h"
92#include "folders/CNetFolder.h"
93#include "folders/CFontsFolder.h"
94#include "folders/CPrinterFolder.h"
95#include "folders/CAdminToolsFolder.h"
96#include "folders/CRecycleBin.h"
97#include "folders/CRecycleBinFolderViewCB.h"
98#include "droptargets/CexeDropHandler.h"
99#include "droptargets/CFSDropTarget.h"
100#include "COpenWithMenu.h"
101#include "CNewMenu.h"
102#include "CSendToMenu.h"
103#include "CCopyMoveToMenu.h"
104#include "CCopyAsPathMenu.h"
105#include "dialogs/filedefext.h"
106#include "dialogs/drvdefext.h"
107#include "CQueryAssociations.h"
108#include "shellmenu/CMenuBand.h"
109#include "shellmenu/CMenuDeskBar.h"
110#include "shellmenu/CMenuSite.h"
111#include "shellmenu/CMergedFolder.h"
112#include "shellmenu/shellmenu.h"
113#include "CUserNotification.h"
114#include "dialogs/folder_options.h"
115#include "shelldesktop/CChangeNotifyServer.h"
116#include "utils.h"
117
118#include <wine/debug.h>
119#include <wine/unicode.h>
120
121extern const GUID CLSID_AdminFolderShortcut;
122extern const GUID CLSID_FontsFolderShortcut;
123extern const GUID CLSID_StartMenu;
124extern const GUID CLSID_MenuBandSite;
125extern const GUID CLSID_OpenWith;
126extern const GUID CLSID_UnixFolder;
127extern const GUID CLSID_UnixDosFolder;
128extern const GUID SHELL32_AdvtShortcutProduct;
129extern const GUID SHELL32_AdvtShortcutComponent;
130
131#define VERBKEY_CCHMAX 64 // Note: 63+\0 seems to be the limit on XP
132
133#define MAX_PROPERTY_SHEET_PAGE 32
134
135#define SHV_CHANGE_NOTIFY (WM_USER + 0x1111)
136#define SHV_UPDATESTATUSBAR (WM_USER + 0x1112)
137
138extern inline
139BOOL
140CALLBACK
141AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam)
142{
143 PROPSHEETHEADERW *pHeader = (PROPSHEETHEADERW *)lParam;
144
145 if (pHeader->nPages < MAX_PROPERTY_SHEET_PAGE)
146 {
147 pHeader->phpage[pHeader->nPages++] = hPage;
148 return TRUE;
149 }
150
151 return FALSE;
152}
153
154static inline HRESULT
155AddPropSheetPage(HPROPSHEETPAGE hPage, LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam)
156{
157 if (!hPage)
158 return E_FAIL;
159 if (pfnAddPage(hPage, lParam))
160 return S_OK;
161 DestroyPropertySheetPage(hPage);
162 return E_FAIL;
163}
164
165template<class T> static UINT CALLBACK
166PropSheetPageLifetimeCallback(HWND hWnd, UINT uMsg, PROPSHEETPAGEW *pPSP)
167{
168 if (uMsg == PSPCB_RELEASE)
169 ((T*)(pPSP->lParam))->Release();
170 return TRUE;
171}
172
173HRESULT
174SHELL32_ShowPropertiesDialog(IDataObject *pdtobj);
175HRESULT
176SHELL32_ShowFilesystemItemPropertiesDialogAsync(IDataObject *pDO);
177HRESULT
178SHELL32_ShowFilesystemItemsPropertiesDialogAsync(HWND hOwner, IDataObject *pDO);
179HRESULT
180SHELL32_ShowShellExtensionProperties(const CLSID *pClsid, IDataObject *pDO);
181HRESULT
182SHELL_ShowItemIDListProperties(LPCITEMIDLIST pidl);
183
184typedef HDSA HDCMA; // DynamicContextMenuArray
185typedef struct _DCMENTRY
186{
187 IContextMenu *pCM;
188 UINT idCmdFirst;
189 UINT idCmdLast;
190} DCMENTRY;
191#define DCMA_Create() ( (HDCMA)DSA_Create(sizeof(DCMENTRY), 4) )
192void DCMA_Destroy(HDCMA hDCMA);
193#define DCMA_GetEntry(hDCMA, iItem) ( (DCMENTRY*)DSA_GetItemPtr((HDSA)(hDCMA), (iItem)) )
194HRESULT DCMA_InvokeCommand(HDCMA hDCMA, CMINVOKECOMMANDINFO *pICI);
195
196UINT
197DCMA_InsertMenuItems(
198 _In_ HDCMA hDCMA,
199 _In_ HDCIA hDCIA,
200 _In_opt_ LPCITEMIDLIST pidlFolder,
201 _In_opt_ IDataObject *pDO,
202 _In_opt_ HKEY *pKeys,
203 _In_opt_ UINT nKeys,
204 _In_ QCMINFO *pQCMI,
205 _In_opt_ UINT fCmf,
206 _In_opt_ IUnknown *pUnkSite);
207
208HRESULT
209SHELL32_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdo, UINT msg);
210PCSTR
211MapFcidmCmdToVerb(_In_ UINT_PTR CmdId);
212UINT
213MapVerbToDfmCmd(_In_ LPCSTR verba);
214UINT
215GetDfmCmd(_In_ IContextMenu *pCM, _In_ LPCSTR verba);
216#define SHELL_ExecuteControlPanelCPL(hwnd, cpl) SHRunControlPanel((cpl), (hwnd))
217
218
219// CStubWindow32 --- The owner window of file property sheets.
220// This window hides taskbar button of property sheet.
221#define CSTUBWINDOW32_CLASSNAME _T("StubWindow32")
222class CStubWindow32 : public CWindowImpl<CStubWindow32>
223{
224 static HWND FindStubWindow(UINT Type, LPCWSTR Path);
225public:
226 DECLARE_WND_CLASS_EX(CSTUBWINDOW32_CLASSNAME, 0, COLOR_WINDOWTEXT)
227 enum {
228 TYPE_FORMATDRIVE = 1,
229 TYPE_PROPERTYSHEET,
230 };
231 static LPCWSTR GetTypePropName() { return L"StubType"; }
232 HRESULT CreateStub(UINT Type, LPCWSTR Path, const POINT *pPt);
233
234 LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
235 {
236 if (HICON hIco = (HICON)SendMessage(WM_SETICON, ICON_BIG, NULL))
237 DestroyIcon(hIco);
238 ::RemovePropW(m_hWnd, GetTypePropName());
239 return 0;
240 }
241
242 BEGIN_MSG_MAP(CStubWindow32)
243 MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
244 END_MSG_MAP()
245};
246
247void PostCabinetMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
248
249BOOL BindCtx_ContainsObject(_In_ IBindCtx *pBindCtx, _In_ LPCWSTR pszName);
250DWORD BindCtx_GetMode(_In_ IBindCtx *pbc, _In_ DWORD dwDefault);
251BOOL SHSkipJunctionBinding(_In_ IBindCtx *pbc, _In_ CLSID *pclsid);
252HRESULT SHIsFileSysBindCtx(_In_ IBindCtx *pBindCtx, _Out_opt_ WIN32_FIND_DATAW *pFindData);
253BOOL Shell_FailForceReturn(_In_ HRESULT hr);
254
255EXTERN_C INT
256Shell_ParseSpecialFolder(_In_ LPCWSTR pszStart, _Out_ LPWSTR *ppch, _Out_ INT *pcch);
257
258EXTERN_C
259HRESULT SHBindToObject(
260 _In_opt_ IShellFolder *psf,
261 _In_ LPCITEMIDLIST pidl,
262 _In_ REFIID riid,
263 _Out_ void **ppvObj);
264
265HRESULT
266SHBindToObjectEx(
267 _In_opt_ IShellFolder *pShellFolder,
268 _In_ LPCITEMIDLIST pidl,
269 _In_opt_ IBindCtx *pBindCtx,
270 _In_ REFIID riid,
271 _Out_ void **ppvObj);
272
273EXTERN_C HRESULT
274SHELL_GetUIObjectOfAbsoluteItem(
275 _In_opt_ HWND hWnd,
276 _In_ PCIDLIST_ABSOLUTE pidl,
277 _In_ REFIID riid, _Out_ void **ppvObj);
278
279HRESULT
280SHELL_DisplayNameOf(
281 _In_opt_ IShellFolder *psf,
282 _In_ LPCITEMIDLIST pidl,
283 _In_opt_ UINT Flags,
284 _Out_ PWSTR *ppStr);
285
286DWORD
287SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes);
288HRESULT SHELL_GetIDListTarget(_In_ LPCITEMIDLIST pidl, _Out_ PIDLIST_ABSOLUTE *ppidl);
289HRESULT SHCoInitializeAnyApartment(VOID);
290
291HRESULT
292SHGetNameAndFlagsW(
293 _In_ LPCITEMIDLIST pidl,
294 _In_ DWORD dwFlags,
295 _Out_opt_ LPWSTR pszText,
296 _In_ UINT cchBuf,
297 _Inout_opt_ DWORD *pdwAttributes);
298
299EXTERN_C HWND BindCtx_GetUIWindow(_In_ IBindCtx *pBindCtx);
300
301EXTERN_C HRESULT
302BindCtx_RegisterObjectParam(
303 _In_ IBindCtx *pBindCtx,
304 _In_ LPOLESTR pszKey,
305 _In_opt_ IUnknown *punk,
306 _Out_ LPBC *ppbc);
307
308BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath);
309BOOL PathIsValidElement(_In_ LPCWSTR pszPath);
310BOOL PathIsDosDevice(_In_ LPCWSTR pszName);
311HRESULT SHELL32_GetDllFromRundll32CommandLine(LPCWSTR pszCmd, LPWSTR pszOut, SIZE_T cchMax);
312HRESULT SHILAppend(_Inout_ LPITEMIDLIST pidl, _Inout_ LPITEMIDLIST *ppidl);
313
314HRESULT DataObject_GetHIDACount(IDataObject *pdo);
315PIDLIST_ABSOLUTE SHELL_CIDA_ILCloneFull(_In_ const CIDA *pCIDA, _In_ UINT Index);
316PIDLIST_ABSOLUTE SHELL_DataObject_ILCloneFullItem(_In_ IDataObject *pDO, _In_ UINT Index);
317HRESULT SHELL_CloneDataObject(_In_ IDataObject *pDO, _Out_ IDataObject **ppDO);
318
319EXTERN_C HRESULT
320IUnknown_InitializeCommand(
321 _In_ IUnknown *pUnk,
322 _In_ PCWSTR pszCommandName,
323 _In_opt_ IPropertyBag *pPB);
324EXTERN_C HRESULT
325InvokeIExecuteCommand(
326 _In_ IExecuteCommand *pEC,
327 _In_ PCWSTR pszCommandName,
328 _In_opt_ IPropertyBag *pPB,
329 _In_opt_ IShellItemArray *pSIA,
330 _In_opt_ LPCMINVOKECOMMANDINFOEX pICI,
331 _In_opt_ IUnknown *pSite);
332EXTERN_C HRESULT
333InvokeIExecuteCommandWithDataObject(
334 _In_ IExecuteCommand *pEC,
335 _In_ PCWSTR pszCommandName,
336 _In_opt_ IPropertyBag *pPB,
337 _In_ IDataObject *pDO,
338 _In_opt_ LPCMINVOKECOMMANDINFOEX pICI,
339 _In_opt_ IUnknown *pSite);
340
341typedef enum _FILEOPCALLBACKEVENT {
342 FOCE_STARTOPERATIONS,
343 FOCE_FINISHOPERATIONS,
344 FOCE_PREMOVEITEM,
345 FOCE_POSTMOVEITEM,
346 FOCE_PRECOPYITEM,
347 FOCE_POSTCOPYITEM,
348 FOCE_PREDELETEITEM,
349 FOCE_POSTDELETEITEM,
350 FOCE_PRERENAMEITEM,
351 FOCE_POSTRENAMEITEM,
352 FOCE_PRENEWITEM,
353 FOCE_POSTNEWITEM
354} FILEOPCALLBACKEVENT;
355typedef HRESULT (CALLBACK *FILEOPCALLBACK)(FILEOPCALLBACKEVENT Event, LPCWSTR Source, LPCWSTR Destination,
356 UINT Attributes, HRESULT hr, void *CallerData);
357int SHELL32_FileOperation(LPSHFILEOPSTRUCTW lpFileOp, FILEOPCALLBACK Callback, void *CallerData);
358HRESULT SHELL_SingleFileOperation(HWND hWnd, UINT Op, PCWSTR Src, PCWSTR Dest, UINT Flags, PWSTR *ppNewName);
359
360#endif /* _PRECOMP_H__ */