2 * Copyright 1999, 2000 Juergen Schmied
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_UNDOCSHELL_H
20 #define __WINE_UNDOCSHELL_H
24 #endif /* defined(__cplusplus) */
26 /****************************************************************************
29 BOOL WINAPI
ILGetDisplayName(
33 /* type parameter for ILGetDisplayNameEx() */
34 #define ILGDN_FORPARSING 0
35 #define ILGDN_NORMAL 1
36 #define ILGDN_INFOLDER 2
38 BOOL WINAPI
ILGetDisplayNameEx(
44 LPITEMIDLIST WINAPI
ILGlobalClone(LPCITEMIDLIST pidl
);
45 void WINAPI
ILGlobalFree(LPITEMIDLIST pidl
);
46 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathA (LPCSTR lpszPath
); //FIXME
47 LPITEMIDLIST WINAPI
SHSimpleIDListFromPathW (LPCWSTR lpszPath
);
49 HRESULT WINAPI
SHILCreateFromPathA (
54 HRESULT WINAPI
SHILCreateFromPathW (
62 BOOL WINAPI
StrRetToStrNA(LPSTR
,DWORD
,LPSTRRET
,const ITEMIDLIST
*);
63 BOOL WINAPI
StrRetToStrNW(LPWSTR
,DWORD
,LPSTRRET
,const ITEMIDLIST
*);
66 /****************************************************************************
67 * SHChangeNotifyRegister API
69 #define SHCNRF_InterruptLevel 0x0001
70 #define SHCNRF_ShellLevel 0x0002
71 #define SHCNRF_RecursiveInterrupt 0x1000 /* Must be combined with SHCNRF_InterruptLevel */
72 #define SHCNRF_NewDelivery 0x8000 /* Messages use shared memory */
75 /****************************************************************************
76 * Shell Common Dialogs
79 /* RunFileDlg flags */
80 #define RFF_NOBROWSE 0x01
81 #define RFF_NODEFAULT 0x02
82 #define RFF_CALCDIRECTORY 0x04
83 #define RFF_NOLABEL 0x08
84 #define RFF_NOSEPARATEMEM 0x20 /* NT only */
86 #define DE_SAMEFILE 0x71
88 /* RunFileFlg notification structure */
95 } NM_RUNFILEDLG
, * LPNM_RUNFILEDLG
;
97 /* RunFileDlg notification return values */
99 #define RF_CANCEL 0x01
100 #define RF_RETRY 0x02
102 void WINAPI
RunFileDlg(
105 LPCWSTR lpstrDirectory
,
107 LPCWSTR lpstrDescription
,
110 void WINAPI
ExitWindowsDialog(HWND hwndOwner
);
112 BOOL WINAPI
SHFindComputer(
113 LPCITEMIDLIST pidlRoot
,
114 LPCITEMIDLIST pidlSavedSearch
);
116 void WINAPI
SHHandleDiskFull(HWND hwndOwner
,
119 int WINAPI
SHOutOfMemoryMessageBox(
124 DWORD WINAPI
SHNetConnectionDialog(
126 LPCWSTR lpstrRemoteName
,
129 /****************************************************************************
130 * Cabinet Window Messages
133 #define CWM_SETPATH (WM_USER + 2)
134 #define CWM_WANTIDLE (WM_USER + 3)
135 #define CWM_GETSETCURRENTINFO (WM_USER + 4)
136 #define CWM_SELECTITEM (WM_USER + 5)
137 #define CWM_SELECTITEMSTR (WM_USER + 6)
138 #define CWM_GETISHELLBROWSER (WM_USER + 7)
139 #define CWM_TESTPATH (WM_USER + 9)
140 #define CWM_STATECHANGE (WM_USER + 10)
141 #define CWM_GETPATH (WM_USER + 12)
143 /* CWM_TESTPATH types */
144 #define CWTP_ISEQUAL 0
145 #define CWTP_ISCHILD 1
147 /* CWM_TESTPATH structure */
152 } CWTESTPATHSTRUCT
,* LPCWTESTPATHSTRUCT
;
154 /****************************************************************************
155 * System Imagelist Routines
158 int WINAPI
Shell_GetCachedImageIndexA(
163 BOOL WINAPI
Shell_GetImageLists(
164 HIMAGELIST
*lphimlLarge
,
165 HIMAGELIST
*lphimlSmall
);
167 HICON WINAPI
SHGetFileIcon(
170 DWORD dwFileAttributes
,
173 BOOL WINAPI
FileIconInit(BOOL bFullInit
);
175 /****************************************************************************
178 /* FileMenu_Create nSelHeight constants */
179 #define FM_DEFAULT_SELHEIGHT -1
180 #define FM_FULL_SELHEIGHT 0
182 /* FileMenu_Create flags */
183 #define FMF_SMALL_ICONS 0x00
184 #define FMF_LARGE_ICONS 0x08
185 #define FMF_NO_COLUMN_BREAK 0x10
187 HMENU WINAPI
FileMenu_Create(
188 COLORREF crBorderColor
,
194 void WINAPI
FileMenu_Destroy(HMENU hMenu
);
196 /* FileMenu_AppendItem constants */
197 #define FM_SEPARATOR (LPCSTR)1
198 #define FM_BLANK_ICON -1
199 #define FM_DEFAULT_HEIGHT 0
201 BOOL WINAPI
FileMenu_AppendItem(
209 /* FileMenu_InsertUsingPidl flags */
210 #define FMF_NO_EMPTY_ITEM 0x01
211 #define FMF_NO_PROGRAM_GROUPS 0x04
213 /* FileMenu_InsertUsingPidl callback function */
214 typedef void (CALLBACK
*LPFNFMCALLBACK
)(LPCITEMIDLIST pidlFolder
, LPCITEMIDLIST pidlFile
);
216 int WINAPI
FileMenu_InsertUsingPidl(
222 LPFNFMCALLBACK lpfnCallback
);
224 int WINAPI
FileMenu_ReplaceUsingPidl(
229 LPFNFMCALLBACK lpfnCallback
);
231 void WINAPI
FileMenu_Invalidate(HMENU hMenu
);
233 HMENU WINAPI
FileMenu_FindSubMenuByPidl(
237 BOOL WINAPI
FileMenu_TrackPopupMenuEx(
245 BOOL WINAPI
FileMenu_GetLastSelectedItemPidls(
247 LPCITEMIDLIST
*ppidlFolder
,
248 LPCITEMIDLIST
*ppidlItem
);
250 LRESULT WINAPI
FileMenu_MeasureItem(
252 LPMEASUREITEMSTRUCT lpmis
);
254 LRESULT WINAPI
FileMenu_DrawItem(
256 LPDRAWITEMSTRUCT lpdis
);
258 BOOL WINAPI
FileMenu_InitMenuPopup(HMENU hMenu
);
260 void WINAPI
FileMenu_AbortInitMenu(void);
262 LRESULT WINAPI
FileMenu_HandleMenuChar(
266 BOOL WINAPI
FileMenu_DeleteAllItems(HMENU hMenu
);
268 BOOL WINAPI
FileMenu_DeleteItemByCmd(
272 BOOL WINAPI
FileMenu_DeleteItemByIndex(
276 BOOL WINAPI
FileMenu_DeleteMenuItemByFirstID(
280 BOOL WINAPI
FileMenu_DeleteSeparator(HMENU hMenu
);
282 BOOL WINAPI
FileMenu_EnableItemByCmd(
287 DWORD WINAPI
FileMenu_GetItemExtent(
291 int WINAPI
FileMenu_AppendFilesForPidl(
296 int WINAPI
FileMenu_AddFilesForPidl(
303 LPFNFMCALLBACK lpfnCallback
);
305 /****************************************************************************
306 * Drag And Drop Routines
309 HRESULT WINAPI
SHRegisterDragDrop(
311 LPDROPTARGET lpDropTarget
);
313 HRESULT WINAPI
SHRevokeDragDrop(HWND hWnd
);
315 BOOL WINAPI
DAD_DragEnter(HWND hWnd
);
317 BOOL WINAPI
DAD_SetDragImageFromListView(
321 BOOL WINAPI
DAD_ShowDragImage(BOOL bShow
);
323 /****************************************************************************
324 * Path Manipulation Routines
327 BOOL WINAPI
PathAppendAW(LPVOID lpszPath1
, LPCVOID lpszPath2
);
329 LPVOID WINAPI
PathCombineAW(LPVOID szDest
, LPCVOID lpszDir
, LPCVOID lpszFile
);
331 LPVOID WINAPI
PathAddBackslashAW(LPVOID path
);
333 LPVOID WINAPI
PathBuildRootAW(LPVOID lpszPath
, int drive
);
335 LPVOID WINAPI
PathFindExtensionAW(LPCVOID path
);
337 LPVOID WINAPI
PathFindFileNameAW(LPCVOID path
);
339 LPVOID WINAPI
PathGetExtensionAW(LPCVOID lpszPath
, DWORD void1
, DWORD void2
);
341 LPVOID WINAPI
PathGetArgsAW(LPVOID lpszPath
);
343 BOOL WINAPI
PathRemoveFileSpecAW(LPVOID lpszPath
);
345 void WINAPI
PathRemoveBlanksAW(LPVOID lpszPath
);
347 VOID WINAPI
PathQuoteSpacesAW(LPVOID path
);
349 void WINAPI
PathUnquoteSpacesAW(LPVOID lpszPath
);
351 BOOL WINAPI
PathIsUNCAW(LPCVOID lpszPath
);
353 BOOL WINAPI
PathIsRelativeAW(LPCVOID lpszPath
);
355 BOOL WINAPI
PathIsRootAW(LPCVOID x
);
357 BOOL WINAPI
PathIsExeAW(LPCVOID lpszPath
);
359 BOOL WINAPI
PathIsDirectoryAW(LPCVOID lpszPath
);
361 BOOL WINAPI
PathFileExistsAW(LPCVOID lpszPath
);
363 BOOL WINAPI
PathMatchSpecAW(LPVOID lpszPath
, LPVOID lpszSpec
);
365 BOOL WINAPI
PathMakeUniqueNameAW(
368 LPCVOID lpszShortName
,
369 LPCVOID lpszLongName
,
370 LPCVOID lpszPathName
);
372 BOOL WINAPI
PathYetAnotherMakeUniqueName(
374 LPCWSTR lpszPathName
,
375 LPCWSTR lpszShortName
,
376 LPCWSTR lpszLongName
);
378 BOOL WINAPI
PathQualifyAW(LPCVOID path
);
381 /* PathResolve flags */
382 #define PRF_CHECKEXISTANCE 0x01
383 #define PRF_EXECUTABLE 0x02
384 #define PRF_QUALIFYONPATH 0x04
385 #define PRF_WINDOWS31 0x08
387 BOOL WINAPI
PathResolveAW(LPVOID lpszPath
, LPCVOID
*alpszPaths
, DWORD dwFlags
);
389 VOID WINAPI
PathSetDlgItemPathAW(HWND hDlg
, int nIDDlgItem
, LPCVOID lpszPath
);
391 /* PathProcessCommand flags */
392 #define PPCF_QUOTEPATH 0x01 /* implies PPCF_INCLUDEARGS */
393 #define PPCF_INCLUDEARGS 0x02
394 //#define PPCF_NODIRECTORIES 0x10 move to shlobj
395 #define PPCF_DONTRESOLVE 0x20
396 #define PPCF_PATHISRELATIVE 0x40
398 HRESULT WINAPI
PathProcessCommandAW(LPCVOID lpszPath
, LPVOID lpszBuff
,
399 DWORD dwBuffSize
, DWORD dwFlags
);
401 void WINAPI
PathStripPathAW(LPVOID lpszPath
);
403 BOOL WINAPI
PathStripToRootAW(LPVOID lpszPath
);
405 void WINAPI
PathRemoveArgsAW(LPVOID lpszPath
);
407 void WINAPI
PathRemoveExtensionAW(LPVOID lpszPath
);
409 int WINAPI
PathParseIconLocationAW(LPVOID lpszPath
);
411 BOOL WINAPI
PathIsSameRootAW(LPCVOID lpszPath1
, LPCVOID lpszPath2
);
413 BOOL WINAPI
PathFindOnPathAW(LPVOID sFile
, LPCVOID
*sOtherDirs
);
415 /****************************************************************************
416 * Shell Namespace Routines
419 /* Generic structure used by several messages */
426 } SFVCBINFO
, * LPSFVCBINFO
;
427 typedef const SFVCBINFO
* LPCSFVCBINFO
;
429 /* SFVCB_SELECTIONCHANGED structure */
436 } SFVSELECTSTATE
, * LPSFVSELECTSTATE
;
437 typedef const SFVSELECTSTATE
* LPCSFVSELECTSTATE
;
439 /* SFVCB_COPYHOOKCALLBACK structure */
449 } SFVCOPYHOOKINFO
, * LPSFVCOPYHOOKINFO
;
450 typedef const SFVCOPYHOOKINFO
* LPCSFVCOPYHOOKINFO
;
452 /* SFVCB_GETDETAILSOF structure */
459 } SFVCOLUMNINFO
, * LPSFVCOLUMNINFO
;
461 /****************************************************************************
465 /* SHWaitForFileToOpen flags */
466 #define SHWFF_ADD 0x01
467 #define SHWFF_REMOVE 0x02
468 #define SHWFF_WAIT 0x04
470 BOOL WINAPI
SHWaitForFileToOpen(
475 WORD WINAPI
ArrangeWindows(
480 CONST HWND
* lpKids
);
482 /* RegisterShellHook types */
483 #define RSH_DEREGISTER 0
484 #define RSH_REGISTER 1
485 #define RSH_REGISTER_PROGMAN 2
486 #define RSH_REGISTER_TASKMAN 3
488 BOOL WINAPI
RegisterShellHook(
492 /* SHCreateDefClassObject callback function */
493 typedef HRESULT (CALLBACK
*LPFNCDCOCALLBACK
)(
498 HRESULT WINAPI
SHCreateDefClassObject(
501 LPFNCDCOCALLBACK lpfnCallback
,
505 void WINAPI
SHFreeUnusedLibraries(void);
507 /* SHCreateLinks flags */
508 #define SHCLF_PREFIXNAME 0x01
509 #define SHCLF_CREATEONDESKTOP 0x02
511 HRESULT WINAPI
SHCreateLinks(
514 LPDATAOBJECT lpDataObject
,
516 LPITEMIDLIST
*lppidlLinks
);
518 DWORD WINAPI
CheckEscapesA(LPSTR string
, DWORD len
);
519 DWORD WINAPI
CheckEscapesW(LPWSTR string
, DWORD len
);
521 /* policy functions */
522 BOOL WINAPI
SHInitRestricted(LPCVOID unused
, LPCVOID inpRegKey
);
524 /* Shell Desktop functions */
526 #define WM_GETISHELLBROWSER (WM_USER+7)
528 BOOL WINAPI
SHDesktopMessageLoop(HANDLE
);
530 #define CSIDL_FOLDER_MASK 0x00ff
532 /* Utility functions */
536 Win32DbgPrint(const char *filename
, int line
, const char *lpFormat
, ...)
544 fname
= strrchr(filename
, '\\');
547 fname
= strrchr(filename
, '/');
557 szMsgStart
= szMsg
+ sprintf(szMsg
, "%s:%d: ", fname
, line
);
559 va_start(vl
, lpFormat
);
560 uRet
= (ULONG
) vsprintf(szMsgStart
, lpFormat
, vl
);
563 OutputDebugStringA(szMsg
);
568 #define DbgPrint(fmt, ...) \
569 Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
571 static inline void DbgDumpMenuInternal(HMENU hmenu
, char* padding
, int padlevel
)
575 padding
[padlevel
] = '.';
576 padding
[padlevel
+ 1] = '.';
577 padding
[padlevel
+ 2] = 0;
579 int count
= GetMenuItemCount(hmenu
);
580 for (int i
= 0; i
< count
; i
++)
582 MENUITEMINFOW mii
= { 0 };
584 mii
.cbSize
= sizeof(mii
);
585 mii
.fMask
= MIIM_STRING
| MIIM_FTYPE
| MIIM_SUBMENU
| MIIM_STATE
| MIIM_ID
;
586 mii
.dwTypeData
= label
;
587 mii
.cch
= _countof(label
);
589 GetMenuItemInfo(hmenu
, i
, TRUE
, &mii
);
591 if (mii
.fType
& MFT_BITMAP
)
592 DbgPrint("%s%2d - %08x: BITMAP %08p (state=%d, has submenu=%s)\n", padding
, i
, mii
.wID
, mii
.hbmpItem
, mii
.fState
, mii
.hSubMenu
? "TRUE" : "FALSE");
593 else if (mii
.fType
& MFT_SEPARATOR
)
594 DbgPrint("%s%2d - %08x ---SEPARATOR---\n", padding
, i
, mii
.wID
);
596 DbgPrint("%s%2d - %08x: %S (state=%d, has submenu=%s)\n", padding
, i
, mii
.wID
, mii
.dwTypeData
, mii
.fState
, mii
.hSubMenu
? "TRUE" : "FALSE");
599 DbgDumpMenuInternal(mii
.hSubMenu
, padding
, padlevel
+ 2);
603 padding
[padlevel
] = 0;
606 static __inline
void DbgDumpMenu(HMENU hmenu
)
609 DbgDumpMenuInternal(hmenu
, padding
, 0);
613 #define FAILED_UNEXPECTEDLY(hr) (FAILED(hr) && (DbgPrint("Unexpected failure %08x.\n", hr), TRUE))
615 #define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
620 #endif /* defined(__cplusplus) */
623 template <class Base
>
624 class CComDebugObject
: public Base
627 CComDebugObject(void * = NULL
)
629 #if DEBUG_CCOMOBJECT_CREATION
630 DbgPrint("%S, this=%08p\n", __FUNCTION__
, static_cast<Base
*>(this));
635 virtual ~CComDebugObject()
637 this->FinalRelease();
638 _pAtlModule
->Unlock();
641 STDMETHOD_(ULONG
, AddRef
)()
643 int rc
= this->InternalAddRef();
644 #if DEBUG_CCOMOBJECT_REFCOUNTING
645 DbgPrint("%s, RefCount is now %d(--)! \n", __FUNCTION__
, rc
);
650 STDMETHOD_(ULONG
, Release
)()
652 int rc
= this->InternalRelease();
654 #if DEBUG_CCOMOBJECT_REFCOUNTING
655 DbgPrint("%s, RefCount is now %d(--)! \n", __FUNCTION__
, rc
);
660 #if DEBUG_CCOMOBJECT_DESTRUCTION
661 DbgPrint("%s, RefCount reached 0 Deleting!\n", __FUNCTION__
);
668 STDMETHOD(QueryInterface
)(REFIID iid
, void **ppvObject
)
670 return this->_InternalQueryInterface(iid
, ppvObject
);
673 static HRESULT WINAPI
CreateInstance(CComDebugObject
<Base
> **pp
)
675 CComDebugObject
<Base
> *newInstance
;
678 ATLASSERT(pp
!= NULL
);
682 hResult
= E_OUTOFMEMORY
;
684 ATLTRY(newInstance
= new CComDebugObject
<Base
>());
685 if (newInstance
!= NULL
)
687 newInstance
->SetVoid(NULL
);
688 newInstance
->InternalFinalConstructAddRef();
689 hResult
= newInstance
->_AtlInitialConstruct();
690 if (SUCCEEDED(hResult
))
691 hResult
= newInstance
->FinalConstruct();
692 if (SUCCEEDED(hResult
))
693 hResult
= newInstance
->_AtlFinalConstruct();
694 newInstance
->InternalFinalConstructRelease();
706 #ifdef DEBUG_CCOMOBJECT
707 # define _CComObject CComDebugObject
709 # define _CComObject CComObject
713 void ReleaseCComPtrExpectZero(CComPtr
<T
>& cptr
, BOOL forceRelease
= FALSE
)
717 int nrc
= cptr
->Release();
720 DbgPrint("WARNING: Unexpected RefCount > 0 (%d)!\n", nrc
);
725 nrc
= cptr
->Release();
733 template<class T
, class R
>
734 HRESULT
inline ShellDebugObjectCreator(REFIID riid
, R
** ppv
)
742 ATLTRY(obj
= new CComDebugObject
<T
>);
744 return E_OUTOFMEMORY
;
745 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(ppv
));
751 template<class T
, class R
>
752 HRESULT
inline ShellObjectCreator(REFIID riid
, R
** ppv
)
760 ATLTRY(obj
= new _CComObject
<T
>);
762 return E_OUTOFMEMORY
;
763 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(ppv
));
769 template<class T
, class R
>
770 HRESULT
inline ShellObjectCreatorInit(REFIID riid
, R
** ppv
)
779 ATLTRY(obj
= new _CComObject
<T
>);
781 return E_OUTOFMEMORY
;
782 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
786 hResult
= obj
->Initialize();
790 *ppv
= result
.Detach();
796 HRESULT
inline ShellObjectCreatorInit(REFIID riid
, void ** ppv
)
799 CComPtr
<IUnknown
> result
;
805 ATLTRY(obj
= new _CComObject
<T
>);
807 return E_OUTOFMEMORY
;
808 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
812 hResult
= obj
->Initialize();
816 *ppv
= result
.Detach();
821 template<class T
, class T1
, class R
>
822 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, REFIID riid
, R
** ppv
)
831 ATLTRY(obj
= new _CComObject
<T
>);
833 return E_OUTOFMEMORY
;
834 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
838 hResult
= obj
->Initialize(initArg1
);
842 *ppv
= result
.Detach();
847 template<class T
, class T1
, class T2
, class R
>
848 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, T2 initArg2
, REFIID riid
, R
** ppv
)
857 ATLTRY(obj
= new _CComObject
<T
>);
859 return E_OUTOFMEMORY
;
860 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
864 hResult
= obj
->Initialize(initArg1
, initArg2
);
868 *ppv
= result
.Detach();
873 template<class T
, class T1
, class T2
, class T3
, class R
>
874 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, T2 initArg2
, T3 initArg3
, REFIID riid
, R
** ppv
)
883 ATLTRY(obj
= new _CComObject
<T
>);
885 return E_OUTOFMEMORY
;
886 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
890 hResult
= obj
->Initialize(initArg1
, initArg2
, initArg3
);
894 *ppv
= result
.Detach();
899 template<class T
, class T1
, class T2
, class T3
, class T4
, class R
>
900 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, T2 initArg2
, T3 initArg3
, T4 initArg4
, REFIID riid
, R
** ppv
)
909 ATLTRY(obj
= new _CComObject
<T
>);
911 return E_OUTOFMEMORY
;
912 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
916 hResult
= obj
->Initialize(initArg1
, initArg2
, initArg3
, initArg4
);
920 *ppv
= result
.Detach();
924 #endif /* __cplusplus */
926 #endif /* __WINE_UNDOCSHELL_H */