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 <ndk/rtlfuncs.h> 27 #include <fmifs/fmifs.h> 28 #include <tchar.h> 29 #include <strsafe.h> 30 #include <atlbase.h> 31 #include <atlcom.h> 32 #include <atlwin.h> 33 #include <atlstr.h> 34 #include <atlsimpcoll.h> 35 #include <atlcoll.h> 36 #include <powrprof.h> 37 #include <winnetwk.h> 38 #include <objsafe.h> 39 #include <regstr.h> 40 41 #include <comctl32_undoc.h> 42 #include <shlguid_undoc.h> 43 #include <shlobj_undoc.h> 44 45 #define SHLWAPI_ISHELLFOLDER_HELPERS 46 #include <shlwapi_undoc.h> 47 48 #include <shellapi.h> 49 #undef ShellExecute 50 #include <undocshell.h> 51 52 /* 53 * For versions < Vista+, redefine ShellMessageBoxW to ShellMessageBoxWrapW 54 * (this is needed to avoid a linker error). On Vista+ onwards, shell32.ShellMessageBoxW 55 * redirects to shlwapi.ShellMessageBoxW so the #define should not be needed. 56 * 57 * However our shell32 is built with _WIN32_WINNT set to 0x600 (Vista+), 58 * yet its exports (especially regarding ShellMessageBoxA/W) are Win2003 59 * compatible. So the #define is still needed, and the check be disabled. 60 */ 61 // #if (_WIN32_WINNT < 0x0600) 62 #define ShellMessageBoxW ShellMessageBoxWrapW 63 // #endif 64 65 #include <browseui_undoc.h> 66 67 #include <shellutils.h> 68 69 #include "shellrecyclebin/recyclebin.h" 70 #include "wine/pidl.h" 71 #include "debughlp.h" 72 #include "wine/shell32_main.h" 73 #include "shresdef.h" 74 #include "wine/cpanel.h" 75 #include "CActiveDesktop.h" 76 #include "CEnumIDListBase.h" 77 #include "shfldr.h" 78 #include "CShellItem.h" 79 #include "CShellLink.h" 80 #include "CFolderItemVerbs.h" 81 #include "CFolderItems.h" 82 #include "CFolder.h" 83 #include "CShellDispatch.h" 84 #include "CDropTargetHelper.h" 85 #include "CFolderOptions.h" 86 #include "folders/CFSFolder.h" 87 #include "folders/CDrivesFolder.h" 88 #include "folders/CDesktopFolder.h" 89 #include "folders/CControlPanelFolder.h" 90 #include "folders/CMyDocsFolder.h" 91 #include "folders/CNetFolder.h" 92 #include "folders/CFontsFolder.h" 93 #include "folders/CPrinterFolder.h" 94 #include "folders/CAdminToolsFolder.h" 95 #include "folders/CRecycleBin.h" 96 #include "droptargets/CexeDropHandler.h" 97 #include "droptargets/CFSDropTarget.h" 98 #include "COpenWithMenu.h" 99 #include "CNewMenu.h" 100 #include "CSendToMenu.h" 101 #include "CCopyMoveToMenu.h" 102 #include "CCopyAsPathMenu.h" 103 #include "dialogs/filedefext.h" 104 #include "dialogs/drvdefext.h" 105 #include "CQueryAssociations.h" 106 #include "shellmenu/CMenuBand.h" 107 #include "shellmenu/CMenuDeskBar.h" 108 #include "shellmenu/CMenuSite.h" 109 #include "shellmenu/CMergedFolder.h" 110 #include "shellmenu/shellmenu.h" 111 #include "CUserNotification.h" 112 #include "dialogs/folder_options.h" 113 #include "shelldesktop/CChangeNotifyServer.h" 114 #include "utils.h" 115 116 #include <wine/debug.h> 117 #include <wine/unicode.h> 118 119 extern const GUID CLSID_AdminFolderShortcut; 120 extern const GUID CLSID_FontsFolderShortcut; 121 extern const GUID CLSID_StartMenu; 122 extern const GUID CLSID_MenuBandSite; 123 extern const GUID CLSID_OpenWith; 124 extern const GUID CLSID_UnixFolder; 125 extern const GUID CLSID_UnixDosFolder; 126 extern const GUID SHELL32_AdvtShortcutProduct; 127 extern const GUID SHELL32_AdvtShortcutComponent; 128 129 #define VERBKEY_CCHMAX 64 // Note: 63+\0 seems to be the limit on XP 130 131 #define MAX_PROPERTY_SHEET_PAGE 32 132 133 extern inline 134 BOOL 135 CALLBACK 136 AddPropSheetPageCallback(HPROPSHEETPAGE hPage, LPARAM lParam) 137 { 138 PROPSHEETHEADERW *pHeader = (PROPSHEETHEADERW *)lParam; 139 140 if (pHeader->nPages < MAX_PROPERTY_SHEET_PAGE) 141 { 142 pHeader->phpage[pHeader->nPages++] = hPage; 143 return TRUE; 144 } 145 146 return FALSE; 147 } 148 149 static inline HRESULT 150 AddPropSheetPage(HPROPSHEETPAGE hPage, LPFNSVADDPROPSHEETPAGE pfnAddPage, LPARAM lParam) 151 { 152 if (!hPage) 153 return E_FAIL; 154 if (pfnAddPage(hPage, lParam)) 155 return S_OK; 156 DestroyPropertySheetPage(hPage); 157 return E_FAIL; 158 } 159 160 template<class T> static UINT CALLBACK 161 PropSheetPageLifetimeCallback(HWND hWnd, UINT uMsg, PROPSHEETPAGEW *pPSP) 162 { 163 if (uMsg == PSPCB_RELEASE) 164 ((T*)(pPSP->lParam))->Release(); 165 return TRUE; 166 } 167 168 EXTERN_C HRESULT WINAPI 169 SHMultiFileProperties(IDataObject *pDataObject, DWORD dwFlags); 170 HRESULT 171 SHELL32_ShowPropertiesDialog(IDataObject *pdtobj); 172 HRESULT 173 SHELL32_ShowFilesystemItemPropertiesDialogAsync(IDataObject *pDO); 174 HRESULT 175 SHELL32_ShowShellExtensionProperties(const CLSID *pClsid, IDataObject *pDO); 176 HRESULT 177 SHELL_ShowItemIDListProperties(LPCITEMIDLIST pidl); 178 179 HRESULT 180 SHELL32_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdo, UINT msg); 181 UINT 182 MapVerbToDfmCmd(_In_ LPCSTR verba); 183 UINT 184 GetDfmCmd(_In_ IContextMenu *pCM, _In_ LPCSTR verba); 185 #define SHELL_ExecuteControlPanelCPL(hwnd, cpl) SHRunControlPanel((cpl), (hwnd)) 186 187 #define CmicFlagsToSeeFlags(flags) ((flags) & SEE_CMIC_COMMON_FLAGS) 188 static inline UINT SeeFlagsToCmicFlags(UINT flags) 189 { 190 if (flags & SEE_MASK_CLASSNAME) 191 flags &= ~(SEE_MASK_HASLINKNAME | SEE_MASK_HASTITLE); 192 return flags & SEE_CMIC_COMMON_FLAGS; 193 } 194 195 196 // CStubWindow32 --- The owner window of file property sheets. 197 // This window hides taskbar button of property sheet. 198 #define CSTUBWINDOW32_CLASSNAME _T("StubWindow32") 199 class CStubWindow32 : public CWindowImpl<CStubWindow32> 200 { 201 static HWND FindStubWindow(UINT Type, LPCWSTR Path); 202 public: 203 DECLARE_WND_CLASS_EX(CSTUBWINDOW32_CLASSNAME, 0, COLOR_WINDOWTEXT) 204 enum { 205 TYPE_FORMATDRIVE = 1, 206 TYPE_PROPERTYSHEET, 207 }; 208 static LPCWSTR GetTypePropName() { return L"StubType"; } 209 HRESULT CreateStub(UINT Type, LPCWSTR Path, const POINT *pPt); 210 211 LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled) 212 { 213 if (HICON hIco = (HICON)SendMessage(WM_SETICON, ICON_BIG, NULL)) 214 DestroyIcon(hIco); 215 ::RemovePropW(m_hWnd, GetTypePropName()); 216 return 0; 217 } 218 219 BEGIN_MSG_MAP(CStubWindow32) 220 MESSAGE_HANDLER(WM_DESTROY, OnDestroy) 221 END_MSG_MAP() 222 }; 223 224 void PostCabinetMessage(UINT Msg, WPARAM wParam, LPARAM lParam); 225 226 HRESULT 227 Shell_TranslateIDListAlias( 228 _In_ LPCITEMIDLIST pidl, 229 _In_ HANDLE hToken, 230 _Out_ LPITEMIDLIST *ppidlAlias, 231 _In_ DWORD dwFlags); 232 233 BOOL BindCtx_ContainsObject(_In_ IBindCtx *pBindCtx, _In_ LPCWSTR pszName); 234 DWORD BindCtx_GetMode(_In_ IBindCtx *pbc, _In_ DWORD dwDefault); 235 BOOL SHSkipJunctionBinding(_In_ IBindCtx *pbc, _In_ CLSID *pclsid); 236 HRESULT SHIsFileSysBindCtx(_In_ IBindCtx *pBindCtx, _Out_opt_ WIN32_FIND_DATAW *pFindData); 237 BOOL Shell_FailForceReturn(_In_ HRESULT hr); 238 239 EXTERN_C INT 240 Shell_ParseSpecialFolder(_In_ LPCWSTR pszStart, _Out_ LPWSTR *ppch, _Out_ INT *pcch); 241 242 HRESULT 243 Shell_DisplayNameOf( 244 _In_ IShellFolder *psf, 245 _In_ LPCITEMIDLIST pidl, 246 _In_ DWORD dwFlags, 247 _Out_ LPWSTR pszBuf, 248 _In_ UINT cchBuf); 249 250 EXTERN_C 251 HRESULT SHBindToObject( 252 _In_opt_ IShellFolder *psf, 253 _In_ LPCITEMIDLIST pidl, 254 _In_ REFIID riid, 255 _Out_ void **ppvObj); 256 257 HRESULT 258 SHBindToObjectEx( 259 _In_opt_ IShellFolder *pShellFolder, 260 _In_ LPCITEMIDLIST pidl, 261 _In_opt_ IBindCtx *pBindCtx, 262 _In_ REFIID riid, 263 _Out_ void **ppvObj); 264 265 EXTERN_C HRESULT 266 SHELL_GetUIObjectOfAbsoluteItem( 267 _In_opt_ HWND hWnd, 268 _In_ PCIDLIST_ABSOLUTE pidl, 269 _In_ REFIID riid, _Out_ void **ppvObj); 270 271 DWORD 272 SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes); 273 HRESULT SHELL_GetIDListTarget(_In_ LPCITEMIDLIST pidl, _Out_ PIDLIST_ABSOLUTE *ppidl); 274 HRESULT SHCoInitializeAnyApartment(VOID); 275 276 HRESULT 277 SHGetNameAndFlagsW( 278 _In_ LPCITEMIDLIST pidl, 279 _In_ DWORD dwFlags, 280 _Out_opt_ LPWSTR pszText, 281 _In_ UINT cchBuf, 282 _Inout_opt_ DWORD *pdwAttributes); 283 284 EXTERN_C HWND BindCtx_GetUIWindow(_In_ IBindCtx *pBindCtx); 285 286 EXTERN_C HRESULT 287 BindCtx_RegisterObjectParam( 288 _In_ IBindCtx *pBindCtx, 289 _In_ LPOLESTR pszKey, 290 _In_opt_ IUnknown *punk, 291 _Out_ LPBC *ppbc); 292 293 BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath); 294 BOOL PathIsValidElement(_In_ LPCWSTR pszPath); 295 BOOL PathIsDosDevice(_In_ LPCWSTR pszName); 296 HRESULT SHILAppend(_Inout_ LPITEMIDLIST pidl, _Inout_ LPITEMIDLIST *ppidl); 297 298 PIDLIST_ABSOLUTE SHELL_CIDA_ILCloneFull(_In_ const CIDA *pCIDA, _In_ UINT Index); 299 PIDLIST_ABSOLUTE SHELL_DataObject_ILCloneFullItem(_In_ IDataObject *pDO, _In_ UINT Index); 300 HRESULT SHELL_CloneDataObject(_In_ IDataObject *pDO, _Out_ IDataObject **ppDO); 301 302 EXTERN_C HRESULT 303 IUnknown_InitializeCommand( 304 _In_ IUnknown *pUnk, 305 _In_ PCWSTR pszCommandName, 306 _In_opt_ IPropertyBag *pPB); 307 EXTERN_C HRESULT 308 InvokeIExecuteCommand( 309 _In_ IExecuteCommand *pEC, 310 _In_ PCWSTR pszCommandName, 311 _In_opt_ IPropertyBag *pPB, 312 _In_opt_ IShellItemArray *pSIA, 313 _In_opt_ LPCMINVOKECOMMANDINFOEX pICI, 314 _In_opt_ IUnknown *pSite); 315 EXTERN_C HRESULT 316 InvokeIExecuteCommandWithDataObject( 317 _In_ IExecuteCommand *pEC, 318 _In_ PCWSTR pszCommandName, 319 _In_opt_ IPropertyBag *pPB, 320 _In_ IDataObject *pDO, 321 _In_opt_ LPCMINVOKECOMMANDINFOEX pICI, 322 _In_opt_ IUnknown *pSite); 323 324 #endif /* _PRECOMP_H__ */ 325