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 extern "C" INT WINAPI
Shell_GetCachedImageIndex(LPCWSTR szPath
, INT nIndex
, UINT bSimulateDoc
);
539 Win32DbgPrint(const char *filename
, int line
, const char *lpFormat
, ...)
547 fname
= strrchr(filename
, '\\');
550 fname
= strrchr(filename
, '/');
560 szMsgStart
= szMsg
+ sprintf(szMsg
, "%s:%d: ", fname
, line
);
562 va_start(vl
, lpFormat
);
563 uRet
= (ULONG
) vsprintf(szMsgStart
, lpFormat
, vl
);
566 OutputDebugStringA(szMsg
);
571 #define DbgPrint(fmt, ...) \
572 Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
574 static inline void DbgDumpMenuInternal(HMENU hmenu
, char* padding
, int padlevel
)
578 padding
[padlevel
] = '.';
579 padding
[padlevel
+ 1] = '.';
580 padding
[padlevel
+ 2] = 0;
582 int count
= GetMenuItemCount(hmenu
);
583 for (int i
= 0; i
< count
; i
++)
585 MENUITEMINFOW mii
= { 0 };
587 mii
.cbSize
= sizeof(mii
);
588 mii
.fMask
= MIIM_STRING
| MIIM_FTYPE
| MIIM_SUBMENU
| MIIM_STATE
| MIIM_ID
;
589 mii
.dwTypeData
= label
;
590 mii
.cch
= _countof(label
);
592 GetMenuItemInfo(hmenu
, i
, TRUE
, &mii
);
594 if (mii
.fType
& MFT_BITMAP
)
595 DbgPrint("%s%2d - %08x: BITMAP %08p (state=%d, has submenu=%s)\n", padding
, i
, mii
.wID
, mii
.hbmpItem
, mii
.fState
, mii
.hSubMenu
? "TRUE" : "FALSE");
596 else if (mii
.fType
& MFT_SEPARATOR
)
597 DbgPrint("%s%2d - %08x ---SEPARATOR---\n", padding
, i
, mii
.wID
);
599 DbgPrint("%s%2d - %08x: %S (state=%d, has submenu=%s)\n", padding
, i
, mii
.wID
, mii
.dwTypeData
, mii
.fState
, mii
.hSubMenu
? "TRUE" : "FALSE");
602 DbgDumpMenuInternal(mii
.hSubMenu
, padding
, padlevel
+ 2);
606 padding
[padlevel
] = 0;
609 static __inline
void DbgDumpMenu(HMENU hmenu
)
612 DbgDumpMenuInternal(hmenu
, padding
, 0);
616 #define FAILED_UNEXPECTEDLY(hr) (FAILED(hr) && (DbgPrint("Unexpected failure %08x.\n", hr), TRUE))
618 #define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
623 #endif /* defined(__cplusplus) */
626 template <class Base
>
627 class CComDebugObject
: public Base
630 CComDebugObject(void * = NULL
)
632 #if DEBUG_CCOMOBJECT_CREATION
633 DbgPrint("%S, this=%08p\n", __FUNCTION__
, static_cast<Base
*>(this));
638 virtual ~CComDebugObject()
640 this->FinalRelease();
641 _pAtlModule
->Unlock();
644 STDMETHOD_(ULONG
, AddRef
)()
646 int rc
= this->InternalAddRef();
647 #if DEBUG_CCOMOBJECT_REFCOUNTING
648 DbgPrint("%s, RefCount is now %d(--)! \n", __FUNCTION__
, rc
);
653 STDMETHOD_(ULONG
, Release
)()
655 int rc
= this->InternalRelease();
657 #if DEBUG_CCOMOBJECT_REFCOUNTING
658 DbgPrint("%s, RefCount is now %d(--)! \n", __FUNCTION__
, rc
);
663 #if DEBUG_CCOMOBJECT_DESTRUCTION
664 DbgPrint("%s, RefCount reached 0 Deleting!\n", __FUNCTION__
);
671 STDMETHOD(QueryInterface
)(REFIID iid
, void **ppvObject
)
673 return this->_InternalQueryInterface(iid
, ppvObject
);
676 static HRESULT WINAPI
CreateInstance(CComDebugObject
<Base
> **pp
)
678 CComDebugObject
<Base
> *newInstance
;
681 ATLASSERT(pp
!= NULL
);
685 hResult
= E_OUTOFMEMORY
;
687 ATLTRY(newInstance
= new CComDebugObject
<Base
>());
688 if (newInstance
!= NULL
)
690 newInstance
->SetVoid(NULL
);
691 newInstance
->InternalFinalConstructAddRef();
692 hResult
= newInstance
->_AtlInitialConstruct();
693 if (SUCCEEDED(hResult
))
694 hResult
= newInstance
->FinalConstruct();
695 if (SUCCEEDED(hResult
))
696 hResult
= newInstance
->_AtlFinalConstruct();
697 newInstance
->InternalFinalConstructRelease();
709 #ifdef DEBUG_CCOMOBJECT
710 # define _CComObject CComDebugObject
712 # define _CComObject CComObject
716 void ReleaseCComPtrExpectZero(CComPtr
<T
>& cptr
, BOOL forceRelease
= FALSE
)
720 int nrc
= cptr
->Release();
723 DbgPrint("WARNING: Unexpected RefCount > 0 (%d)!\n", nrc
);
728 nrc
= cptr
->Release();
736 template<class T
, class R
>
737 HRESULT
inline ShellDebugObjectCreator(REFIID riid
, R
** ppv
)
745 ATLTRY(obj
= new CComDebugObject
<T
>);
747 return E_OUTOFMEMORY
;
748 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(ppv
));
754 template<class T
, class R
>
755 HRESULT
inline ShellObjectCreator(REFIID riid
, R
** ppv
)
763 ATLTRY(obj
= new _CComObject
<T
>);
765 return E_OUTOFMEMORY
;
766 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(ppv
));
772 template<class T
, class R
>
773 HRESULT
inline ShellObjectCreatorInit(REFIID riid
, R
** ppv
)
782 ATLTRY(obj
= new _CComObject
<T
>);
784 return E_OUTOFMEMORY
;
785 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
789 hResult
= obj
->Initialize();
793 *ppv
= result
.Detach();
799 HRESULT
inline ShellObjectCreatorInit(REFIID riid
, void ** ppv
)
802 CComPtr
<IUnknown
> result
;
808 ATLTRY(obj
= new _CComObject
<T
>);
810 return E_OUTOFMEMORY
;
811 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
815 hResult
= obj
->Initialize();
819 *ppv
= result
.Detach();
824 template<class T
, class T1
, class R
>
825 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, REFIID riid
, R
** ppv
)
834 ATLTRY(obj
= new _CComObject
<T
>);
836 return E_OUTOFMEMORY
;
837 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
841 hResult
= obj
->Initialize(initArg1
);
845 *ppv
= result
.Detach();
850 template<class T
, class T1
, class T2
, class R
>
851 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, T2 initArg2
, REFIID riid
, R
** ppv
)
860 ATLTRY(obj
= new _CComObject
<T
>);
862 return E_OUTOFMEMORY
;
863 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
867 hResult
= obj
->Initialize(initArg1
, initArg2
);
871 *ppv
= result
.Detach();
876 template<class T
, class T1
, class T2
, class T3
, class R
>
877 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, T2 initArg2
, T3 initArg3
, REFIID riid
, R
** ppv
)
886 ATLTRY(obj
= new _CComObject
<T
>);
888 return E_OUTOFMEMORY
;
889 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
893 hResult
= obj
->Initialize(initArg1
, initArg2
, initArg3
);
897 *ppv
= result
.Detach();
902 template<class T
, class T1
, class T2
, class T3
, class T4
, class R
>
903 HRESULT
inline ShellObjectCreatorInit(T1 initArg1
, T2 initArg2
, T3 initArg3
, T4 initArg4
, REFIID riid
, R
** ppv
)
912 ATLTRY(obj
= new _CComObject
<T
>);
914 return E_OUTOFMEMORY
;
915 hResult
= obj
->QueryInterface(riid
, reinterpret_cast<void **>(&result
));
919 hResult
= obj
->Initialize(initArg1
, initArg2
, initArg3
, initArg4
);
923 *ppv
= result
.Detach();
927 #endif /* __cplusplus */
929 #endif /* __WINE_UNDOCSHELL_H */