4 * Copyright 2003 Martin Fuchs
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or(at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "wine/port.h"
30 #define NONAMELESSUNION
31 #define NONAMELESSSTRUCT
44 #include "enumidlist.h"
46 #include "undocshell.h"
47 #include "shell32_main.h"
50 #include "shellfolder.h"
51 #include "wine/debug.h"
55 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
57 /***********************************************************************
58 * control panel implementation in shell namespace
62 IShellFolder2Vtbl
*lpVtbl
;
64 IPersistFolder2Vtbl
*lpVtblPersistFolder2
;
65 IShellExecuteHookWVtbl
*lpVtblShellExecuteHookW
;
66 IShellExecuteHookAVtbl
*lpVtblShellExecuteHookA
;
68 IUnknown
*pUnkOuter
; /* used for aggregation */
70 /* both paths are parsible from the desktop */
71 LPITEMIDLIST pidlRoot
; /* absolute pidl */
72 int dwAttributes
; /* attributes returned by GetAttributesOf FIXME: use it */
75 static IShellFolder2Vtbl vt_ShellFolder2
;
76 static IPersistFolder2Vtbl vt_PersistFolder2
;
77 static IShellExecuteHookWVtbl vt_ShellExecuteHookW
;
78 static IShellExecuteHookAVtbl vt_ShellExecuteHookA
;
80 #define _IPersistFolder2_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblPersistFolder2)))
81 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
83 #define IShellExecuteHookW_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookW)))
84 #define _ICOM_THIS_From_IShellExecuteHookW(class, name) class* This = (class*)(((char*)name)-IShellExecuteHookW_Offset);
86 #define IShellExecuteHookA_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookA)))
87 #define _ICOM_THIS_From_IShellExecuteHookA(class, name) class* This = (class*)(((char*)name)-IShellExecuteHookA_Offset);
91 converts This to a interface pointer
93 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
94 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
95 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl)
97 #define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2)
98 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2)
99 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
100 #define _IShellExecuteHookW_(This) (IShellExecuteHookW*)&(This->lpVtblShellExecuteHookW)
101 #define _IShellExecuteHookA_(This) (IShellExecuteHookA*)&(This->lpVtblShellExecuteHookA)
103 /***********************************************************************
104 * IShellFolder [ControlPanel] implementation
107 static shvheader ControlPanelSFHeader
[] = {
108 {IDS_SHV_COLUMN8
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},/*FIXME*/
109 {IDS_SHV_COLUMN9
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 200},/*FIXME*/
112 #define CONROLPANELSHELLVIEWCOLUMNS 2
114 /**************************************************************************
115 * IControlPanel_Constructor
117 HRESULT WINAPI
IControlPanel_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
121 TRACE("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid(riid
));
125 if (pUnkOuter
&& !IsEqualIID (riid
, &IID_IUnknown
))
126 return CLASS_E_NOAGGREGATION
;
128 sf
= (ICPanelImpl
*) LocalAlloc(GMEM_ZEROINIT
, sizeof(ICPanelImpl
));
130 return E_OUTOFMEMORY
;
133 sf
->lpVtbl
= &vt_ShellFolder2
;
134 sf
->lpVtblPersistFolder2
= &vt_PersistFolder2
;
135 sf
->lpVtblShellExecuteHookW
= &vt_ShellExecuteHookW
;
136 sf
->lpVtblShellExecuteHookA
= &vt_ShellExecuteHookA
;
137 sf
->pidlRoot
= _ILCreateControlPanel(); /* my qualified pidl */
138 sf
->pUnkOuter
= pUnkOuter
? pUnkOuter
: _IUnknown_ (sf
);
140 if (!SUCCEEDED(IUnknown_QueryInterface(_IUnknown_(sf
), riid
, ppv
))) {
141 IUnknown_Release(_IUnknown_(sf
));
142 return E_NOINTERFACE
;
145 TRACE("--(%p)\n", sf
);
149 /**************************************************************************
150 * ISF_ControlPanel_fnQueryInterface
152 * NOTES supports not IPersist/IPersistFolder
154 static HRESULT WINAPI
ISF_ControlPanel_fnQueryInterface(IShellFolder2
* iface
, REFIID riid
, LPVOID
* ppvObject
)
156 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
158 TRACE("(%p)->(%s,%p)\n", This
, shdebugstr_guid(riid
), ppvObject
);
162 if (IsEqualIID(riid
, &IID_IUnknown
) ||
163 IsEqualIID(riid
, &IID_IShellFolder
) || IsEqualIID(riid
, &IID_IShellFolder2
))
165 else if (IsEqualIID(riid
, &IID_IPersist
) ||
166 IsEqualIID(riid
, &IID_IPersistFolder
) || IsEqualIID(riid
, &IID_IPersistFolder2
))
167 *ppvObject
= _IPersistFolder2_(This
);
168 else if (IsEqualIID(riid
, &IID_IShellExecuteHookW
))
169 *ppvObject
= _IShellExecuteHookW_(This
);
170 else if (IsEqualIID(riid
, &IID_IShellExecuteHookA
))
171 *ppvObject
= _IShellExecuteHookA_(This
);
174 IUnknown_AddRef((IUnknown
*)(*ppvObject
));
175 TRACE("-- Interface:(%p)->(%p)\n", ppvObject
, *ppvObject
);
178 TRACE("-- Interface: E_NOINTERFACE\n");
179 return E_NOINTERFACE
;
182 static ULONG WINAPI
ISF_ControlPanel_fnAddRef(IShellFolder2
* iface
)
184 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
186 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
188 return ++(This
->ref
);
191 static ULONG WINAPI
ISF_ControlPanel_fnRelease(IShellFolder2
* iface
)
193 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
195 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
197 if (!--(This
->ref
)) {
198 TRACE("-- destroying IShellFolder(%p)\n", This
);
200 SHFree(This
->pidlRoot
);
201 LocalFree((HLOCAL
) This
);
207 /**************************************************************************
208 * ISF_ControlPanel_fnParseDisplayName
210 static HRESULT WINAPI
211 ISF_ControlPanel_fnParseDisplayName(IShellFolder2
* iface
,
214 LPOLESTR lpszDisplayName
,
215 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
217 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
219 HRESULT hr
= E_INVALIDARG
;
221 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
222 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
), pchEaten
, ppidl
, pdwAttributes
);
228 TRACE("(%p)->(-- ret=0x%08lx)\n", This
, hr
);
233 static LPITEMIDLIST
_ILCreateCPanelApplet(LPCSTR name
, LPCSTR displayName
,
234 LPCSTR comment
, int iconIdx
)
239 int size0
= (char*)&tmp
.u
.cpanel
.szName
-(char*)&tmp
.u
.cpanel
;
243 tmp
.type
= PT_CPLAPPLET
;
244 tmp
.u
.cpanel
.dummy
= 0;
245 tmp
.u
.cpanel
.iconIdx
= iconIdx
;
250 tmp
.u
.cpanel
.offsDispName
= l
+1;
251 l
= strlen(displayName
);
254 tmp
.u
.cpanel
.offsComment
= tmp
.u
.cpanel
.offsDispName
+1+l
;
258 pidl
= SHAlloc(size
+4);
262 pidl
->mkid
.cb
= size
+2;
263 memcpy(pidl
->mkid
.abID
, &tmp
, 2+size0
);
265 p
= &((PIDLDATA
*)pidl
->mkid
.abID
)->u
.cpanel
;
266 strcpy(p
->szName
, name
);
267 strcpy(p
->szName
+tmp
.u
.cpanel
.offsDispName
, displayName
);
268 strcpy(p
->szName
+tmp
.u
.cpanel
.offsComment
, comment
);
270 *(WORD
*)((char*)pidl
+(size
+2)) = 0;
277 /**************************************************************************
278 * _ILGetCPanelPointer()
279 * gets a pointer to the control panel struct stored in the pidl
281 static PIDLCPanelStruct
* _ILGetCPanelPointer(LPCITEMIDLIST pidl
)
283 LPPIDLDATA pdata
= _ILGetDataPointer(pidl
);
285 if (pdata
&& pdata
->type
==PT_CPLAPPLET
)
286 return (PIDLCPanelStruct
*)&(pdata
->u
.cpanel
);
291 /**************************************************************************
292 * ISF_ControlPanel_fnEnumObjects
294 static BOOL
SHELL_RegisterCPanelApp(IEnumIDList
* list
, LPCSTR path
)
303 char displayName
[MAX_PATH
];
304 char comment
[MAX_PATH
];
306 WCHAR wpath
[MAX_PATH
];
308 MultiByteToWideChar(CP_ACP
, 0, path
, -1, wpath
, MAX_PATH
);
311 applet
= Control_LoadApplet(0, wpath
, &panel
);
315 for(i
=0; i
<applet
->count
; ++i
)
317 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].szName
, -1, displayName
, MAX_PATH
, 0, 0);
318 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].szInfo
, -1, comment
, MAX_PATH
, 0, 0);
320 applet
->proc(0, CPL_INQUIRE
, i
, (LPARAM
)&info
);
323 iconIdx
= -info
.idIcon
; /* negative icon index instead of icon number */
327 pidl
= _ILCreateCPanelApplet(path
, displayName
, comment
, iconIdx
);
330 AddToEnumList(list
, pidl
);
332 Control_UnloadApplet(applet
);
337 static int SHELL_RegisterRegistryCPanelApps(IEnumIDList
* list
, HKEY hkey_root
, LPCSTR szRepPath
)
340 char value
[MAX_PATH
];
345 if (RegOpenKeyA(hkey_root
, szRepPath
, &hkey
) == ERROR_SUCCESS
)
351 DWORD nameLen
= MAX_PATH
;
352 DWORD valueLen
= MAX_PATH
;
354 if (RegEnumValueA(hkey
, idx
, name
, &nameLen
, NULL
, NULL
, (LPBYTE
)&value
, &valueLen
) != ERROR_SUCCESS
)
357 if (SHELL_RegisterCPanelApp(list
, value
))
366 static int SHELL_RegisterCPanelFolders(IEnumIDList
* list
, HKEY hkey_root
, LPCSTR szRepPath
)
373 if (RegOpenKeyA(hkey_root
, szRepPath
, &hkey
) == ERROR_SUCCESS
)
378 if (RegEnumKeyA(hkey
, idx
, name
, MAX_PATH
) != ERROR_SUCCESS
)
383 LPITEMIDLIST pidl
= _ILCreateGuidFromStrA(name
);
385 if (pidl
&& AddToEnumList(list
, pidl
))
396 /**************************************************************************
397 * CreateCPanelEnumList()
399 static BOOL
CreateCPanelEnumList(
403 CHAR szPath
[MAX_PATH
];
404 WIN32_FIND_DATAA wfd
;
407 TRACE("(%p)->(flags=0x%08lx) \n",iface
,dwFlags
);
409 /* enumerate control panel folders folders */
410 if (dwFlags
& SHCONTF_FOLDERS
)
411 SHELL_RegisterCPanelFolders(iface
, HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
413 /* enumerate the control panel applets */
414 if (dwFlags
& SHCONTF_NONFOLDERS
)
418 GetSystemDirectoryA(szPath
, MAX_PATH
);
419 p
= PathAddBackslashA(szPath
);
422 TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface
,debugstr_a(szPath
));
423 hFile
= FindFirstFileA(szPath
, &wfd
);
425 if (hFile
!= INVALID_HANDLE_VALUE
)
429 if (!(dwFlags
& SHCONTF_INCLUDEHIDDEN
) && (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_HIDDEN
))
432 if (!(wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
433 strcpy(p
, wfd
.cFileName
);
434 SHELL_RegisterCPanelApp((IEnumIDList
*)iface
, szPath
);
436 } while(FindNextFileA(hFile
, &wfd
));
440 SHELL_RegisterRegistryCPanelApps((IEnumIDList
*)iface
, HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
441 SHELL_RegisterRegistryCPanelApps((IEnumIDList
*)iface
, HKEY_CURRENT_USER
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
446 /**************************************************************************
447 * ISF_ControlPanel_fnEnumObjects
449 static HRESULT WINAPI
450 ISF_ControlPanel_fnEnumObjects(IShellFolder2
* iface
, HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
452 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
454 TRACE("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This
, hwndOwner
, dwFlags
, ppEnumIDList
);
456 *ppEnumIDList
= IEnumIDList_Constructor();
458 CreateCPanelEnumList(*ppEnumIDList
, dwFlags
);
460 TRACE("--(%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
462 return(*ppEnumIDList
) ? S_OK
: E_OUTOFMEMORY
;
465 /**************************************************************************
466 * ISF_ControlPanel_fnBindToObject
468 static HRESULT WINAPI
469 ISF_ControlPanel_fnBindToObject(IShellFolder2
* iface
, LPCITEMIDLIST pidl
,
470 LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
472 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
474 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
476 return SHELL32_BindToChild(This
->pidlRoot
, NULL
, pidl
, riid
, ppvOut
);
479 /**************************************************************************
480 * ISF_ControlPanel_fnBindToStorage
482 static HRESULT WINAPI
483 ISF_ControlPanel_fnBindToStorage(IShellFolder2
* iface
,
484 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
486 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
488 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
494 /**************************************************************************
495 * ISF_ControlPanel_fnCompareIDs
498 static HRESULT WINAPI
499 ISF_ControlPanel_fnCompareIDs(IShellFolder2
* iface
, LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
501 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
505 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
506 nReturn
= SHELL32_CompareIDs(_IShellFolder_(This
), lParam
, pidl1
, pidl2
);
507 TRACE("-- %i\n", nReturn
);
511 /**************************************************************************
512 * ISF_ControlPanel_fnCreateViewObject
514 static HRESULT WINAPI
515 ISF_ControlPanel_fnCreateViewObject(IShellFolder2
* iface
, HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
517 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
519 LPSHELLVIEW pShellView
;
520 HRESULT hr
= E_INVALIDARG
;
522 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This
, hwndOwner
, shdebugstr_guid(riid
), ppvOut
);
527 if (IsEqualIID(riid
, &IID_IDropTarget
)) {
528 WARN("IDropTarget not implemented\n");
530 } else if (IsEqualIID(riid
, &IID_IContextMenu
)) {
531 WARN("IContextMenu not implemented\n");
533 } else if (IsEqualIID(riid
, &IID_IShellView
)) {
534 pShellView
= IShellView_Constructor((IShellFolder
*) iface
);
536 hr
= IShellView_QueryInterface(pShellView
, riid
, ppvOut
);
537 IShellView_Release(pShellView
);
541 TRACE("--(%p)->(interface=%p)\n", This
, ppvOut
);
545 /**************************************************************************
546 * ISF_ControlPanel_fnGetAttributesOf
548 static HRESULT WINAPI
549 ISF_ControlPanel_fnGetAttributesOf(IShellFolder2
* iface
, UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
551 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
555 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This
, cidl
, apidl
, *rgfInOut
);
557 if ((!cidl
) ||(!apidl
) ||(!rgfInOut
))
563 while(cidl
> 0 && *apidl
) {
565 SHELL32_GetItemAttributes(_IShellFolder_(This
), *apidl
, rgfInOut
);
570 TRACE("-- result=0x%08lx\n", *rgfInOut
);
574 /**************************************************************************
575 * ISF_ControlPanel_fnGetUIObjectOf
578 * HWND hwndOwner, //[in ] Parent window for any output
579 * UINT cidl, //[in ] array size
580 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
581 * REFIID riid, //[in ] Requested Interface
582 * UINT* prgfInOut, //[ ] reserved
583 * LPVOID* ppvObject) //[out] Resulting Interface
586 static HRESULT WINAPI
587 ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2
* iface
,
589 UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
591 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
594 IUnknown
*pObj
= NULL
;
595 HRESULT hr
= E_INVALIDARG
;
597 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
598 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid(riid
), prgfInOut
, ppvOut
);
603 if (IsEqualIID(riid
, &IID_IContextMenu
) &&(cidl
>= 1)) {
604 pObj
= (LPUNKNOWN
) ISvItemCm_Constructor((IShellFolder
*) iface
, This
->pidlRoot
, apidl
, cidl
);
606 } else if (IsEqualIID(riid
, &IID_IDataObject
) &&(cidl
>= 1)) {
607 pObj
= (LPUNKNOWN
) IDataObject_Constructor(hwndOwner
, This
->pidlRoot
, apidl
, cidl
);
609 } else if (IsEqualIID(riid
, &IID_IExtractIconA
) &&(cidl
== 1)) {
610 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
611 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor(pidl
);
614 } else if (IsEqualIID(riid
, &IID_IExtractIconW
) &&(cidl
== 1)) {
615 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
616 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor(pidl
);
619 } else if ((IsEqualIID(riid
,&IID_IShellLinkW
) || IsEqualIID(riid
,&IID_IShellLinkA
))
621 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
622 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
,(LPVOID
*)&pObj
);
628 if (SUCCEEDED(hr
) && !pObj
)
633 TRACE("(%p)->hr=0x%08lx\n", This
, hr
);
637 /**************************************************************************
638 * ISF_ControlPanel_fnGetDisplayNameOf
640 static HRESULT WINAPI
ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2
* iface
, LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
642 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
644 CHAR szPath
[MAX_PATH
*2];
645 PIDLCPanelStruct
* pcpanel
;
649 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n", This
, pidl
, dwFlags
, strRet
);
652 if (!pidl
|| !strRet
)
655 pcpanel
= _ILGetCPanelPointer(pidl
);
658 lstrcpyA(szPath
, pcpanel
->szName
+pcpanel
->offsDispName
);
660 if (!(dwFlags
& SHGDN_FORPARSING
))
661 FIXME("retrieve display name from control panel app\n");
663 /* take names of special folders only if its only this folder */
664 else if (_ILIsSpecialFolder(pidl
)) {
665 BOOL bSimplePidl
= _ILIsPidlSimple(pidl
);
668 _ILSimpleGetText(pidl
, szPath
, MAX_PATH
); /* append my own path */
670 FIXME("special pidl\n");
673 if ((dwFlags
& SHGDN_FORPARSING
) && !bSimplePidl
) { /* go deeper if needed */
676 PathAddBackslashA(szPath
); /*FIXME*/
677 len
= lstrlenA(szPath
);
680 (SHELL32_GetDisplayNameOfChild(iface
, pidl
, dwFlags
| SHGDN_INFOLDER
, szPath
+ len
, MAX_PATH
- len
)))
681 return E_OUTOFMEMORY
;
685 strRet
->uType
= STRRET_CSTR
;
686 lstrcpynA(strRet
->u
.cStr
, szPath
, MAX_PATH
);
688 TRACE("--(%p)->(%s)\n", This
, szPath
);
692 /**************************************************************************
693 * ISF_ControlPanel_fnSetNameOf
694 * Changes the name of a file object or subfolder, possibly changing its item
695 * identifier in the process.
698 * HWND hwndOwner, //[in ] Owner window for output
699 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
700 * LPCOLESTR lpszName, //[in ] the items new display name
701 * DWORD dwFlags, //[in ] SHGNO formatting flags
702 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
704 static HRESULT WINAPI
ISF_ControlPanel_fnSetNameOf(IShellFolder2
* iface
, HWND hwndOwner
, LPCITEMIDLIST pidl
, /*simple pidl */
705 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
707 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
708 FIXME("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This
, hwndOwner
, pidl
, debugstr_w(lpName
), dwFlags
, pPidlOut
);
712 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2
* iface
, GUID
* pguid
)
714 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
715 FIXME("(%p)\n", This
);
718 static HRESULT WINAPI
ISF_ControlPanel_fnEnumSearches(IShellFolder2
* iface
, IEnumExtraSearch
** ppenum
)
720 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
721 FIXME("(%p)\n", This
);
724 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2
* iface
, DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
726 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
728 TRACE("(%p)\n", This
);
730 if (pSort
) *pSort
= 0;
731 if (pDisplay
) *pDisplay
= 0;
734 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
736 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
738 TRACE("(%p)\n", This
);
740 if (!pcsFlags
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
) return E_INVALIDARG
;
741 *pcsFlags
= ControlPanelSFHeader
[iColumn
].pcsFlags
;
744 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsEx(IShellFolder2
* iface
, LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
746 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
747 FIXME("(%p)\n", This
);
751 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsOf(IShellFolder2
* iface
, LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
753 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
756 TRACE("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
758 if (!psd
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
)
762 psd
->fmt
= ControlPanelSFHeader
[iColumn
].fmt
;
763 psd
->cxChar
= ControlPanelSFHeader
[iColumn
].cxChar
;
764 psd
->str
.uType
= STRRET_CSTR
;
765 LoadStringA(shell32_hInstance
, ControlPanelSFHeader
[iColumn
].colnameid
, psd
->str
.u
.cStr
, MAX_PATH
);
768 psd
->str
.u
.cStr
[0] = 0x00;
769 psd
->str
.uType
= STRRET_CSTR
;
772 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
, SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
774 case 1: /* comment */
775 _ILGetFileType(pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
783 static HRESULT WINAPI
ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
785 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
786 FIXME("(%p)\n", This
);
790 static IShellFolder2Vtbl vt_ShellFolder2
=
793 ISF_ControlPanel_fnQueryInterface
,
794 ISF_ControlPanel_fnAddRef
,
795 ISF_ControlPanel_fnRelease
,
796 ISF_ControlPanel_fnParseDisplayName
,
797 ISF_ControlPanel_fnEnumObjects
,
798 ISF_ControlPanel_fnBindToObject
,
799 ISF_ControlPanel_fnBindToStorage
,
800 ISF_ControlPanel_fnCompareIDs
,
801 ISF_ControlPanel_fnCreateViewObject
,
802 ISF_ControlPanel_fnGetAttributesOf
,
803 ISF_ControlPanel_fnGetUIObjectOf
,
804 ISF_ControlPanel_fnGetDisplayNameOf
,
805 ISF_ControlPanel_fnSetNameOf
,
808 ISF_ControlPanel_fnGetDefaultSearchGUID
,
809 ISF_ControlPanel_fnEnumSearches
,
810 ISF_ControlPanel_fnGetDefaultColumn
,
811 ISF_ControlPanel_fnGetDefaultColumnState
,
812 ISF_ControlPanel_fnGetDetailsEx
,
813 ISF_ControlPanel_fnGetDetailsOf
,
814 ISF_ControlPanel_fnMapColumnToSCID
817 /************************************************************************
818 * ICPanel_PersistFolder2_QueryInterface
820 static HRESULT WINAPI
ICPanel_PersistFolder2_QueryInterface(IPersistFolder2
* iface
, REFIID iid
, LPVOID
* ppvObject
)
822 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl
, iface
);
824 TRACE("(%p)\n", This
);
826 return IUnknown_QueryInterface(_IUnknown_(This
), iid
, ppvObject
);
829 /************************************************************************
830 * ICPanel_PersistFolder2_AddRef
832 static ULONG WINAPI
ICPanel_PersistFolder2_AddRef(IPersistFolder2
* iface
)
834 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl
, iface
);
836 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
838 return IUnknown_AddRef(_IUnknown_(This
));
841 /************************************************************************
842 * ISFPersistFolder_Release
844 static ULONG WINAPI
ICPanel_PersistFolder2_Release(IPersistFolder2
* iface
)
846 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl
, iface
);
848 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
850 return IUnknown_Release(_IUnknown_(This
));
853 /************************************************************************
854 * ICPanel_PersistFolder2_GetClassID
856 static HRESULT WINAPI
ICPanel_PersistFolder2_GetClassID(IPersistFolder2
* iface
, CLSID
* lpClassId
)
858 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl
, iface
);
860 TRACE("(%p)\n", This
);
864 *lpClassId
= CLSID_ControlPanel
;
869 /************************************************************************
870 * ICPanel_PersistFolder2_Initialize
872 * NOTES: it makes no sense to change the pidl
874 static HRESULT WINAPI
ICPanel_PersistFolder2_Initialize(IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
876 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl
, iface
);
877 TRACE("(%p)->(%p)\n", This
, pidl
);
881 /**************************************************************************
882 * IPersistFolder2_fnGetCurFolder
884 static HRESULT WINAPI
ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2
* iface
, LPITEMIDLIST
* pidl
)
886 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl
, iface
);
888 TRACE("(%p)->(%p)\n", This
, pidl
);
892 *pidl
= ILClone(This
->pidlRoot
);
896 static IPersistFolder2Vtbl vt_PersistFolder2
=
899 ICPanel_PersistFolder2_QueryInterface
,
900 ICPanel_PersistFolder2_AddRef
,
901 ICPanel_PersistFolder2_Release
,
902 ICPanel_PersistFolder2_GetClassID
,
903 ICPanel_PersistFolder2_Initialize
,
904 ICPanel_PersistFolder2_GetCurFolder
907 HRESULT WINAPI
CPanel_GetIconLocationA(LPITEMIDLIST pidl
, LPSTR szIconFile
, UINT cchMax
, int* piIndex
)
909 PIDLCPanelStruct
* pcpanel
= _ILGetCPanelPointer(pidl
);
914 lstrcpyA(szIconFile
, pcpanel
->szName
);
915 *piIndex
= pcpanel
->iconIdx
!=-1? pcpanel
->iconIdx
: 0;
920 HRESULT WINAPI
CPanel_GetIconLocationW(LPITEMIDLIST pidl
, LPWSTR szIconFile
, UINT cchMax
, int* piIndex
)
922 PIDLCPanelStruct
* pcpanel
= _ILGetCPanelPointer(pidl
);
927 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, szIconFile
, cchMax
);
928 *piIndex
= pcpanel
->iconIdx
!=-1? pcpanel
->iconIdx
: 0;
934 /**************************************************************************
935 * IShellExecuteHookW Implementation
938 static HRESULT WINAPI
IShellExecuteHookW_fnQueryInterface(IShellExecuteHookW
* iface
, REFIID riid
, void** ppvObject
)
940 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl
, iface
);
942 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
944 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
947 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnAddRef(IShellExecuteHookW
* iface
)
949 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl
, iface
);
951 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
953 return IUnknown_AddRef(This
->pUnkOuter
);
956 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnRelease(IShellExecuteHookW
* iface
)
958 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl
, iface
);
960 TRACE("(%p)\n", This
);
962 return IUnknown_Release(This
->pUnkOuter
);
965 static HRESULT WINAPI
IShellExecuteHookW_fnExecute(IShellExecuteHookW
* iface
, LPSHELLEXECUTEINFOW psei
)
967 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
969 SHELLEXECUTEINFOW sei_tmp
;
970 PIDLCPanelStruct
* pcpanel
;
971 WCHAR path
[MAX_PATH
];
975 TRACE("(%p)->execute(%p)\n", This
, psei
);
980 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
986 l
= 1 + MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, path
+1, MAX_PATH
);
988 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
992 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
+pcpanel
->offsDispName
, -1, path
+l
, MAX_PATH
);
994 memcpy(&sei_tmp
, psei
, sizeof(sei_tmp
));
995 sei_tmp
.lpFile
= path
;
996 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
998 ret
= ShellExecuteExW(&sei_tmp
);
1005 static IShellExecuteHookWVtbl vt_ShellExecuteHookW
=
1008 IShellExecuteHookW_fnQueryInterface
,
1009 IShellExecuteHookW_fnAddRef
,
1010 IShellExecuteHookW_fnRelease
,
1012 IShellExecuteHookW_fnExecute
1016 /**************************************************************************
1017 * IShellExecuteHookA Implementation
1020 static HRESULT WINAPI
IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA
* iface
, REFIID riid
, void** ppvObject
)
1022 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl
, iface
);
1024 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
1026 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
1029 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnAddRef(IShellExecuteHookA
* iface
)
1031 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl
, iface
);
1033 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
1035 return IUnknown_AddRef(This
->pUnkOuter
);
1038 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnRelease(IShellExecuteHookA
* iface
)
1040 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl
, iface
);
1042 TRACE("(%p)\n", This
);
1044 return IUnknown_Release(This
->pUnkOuter
);
1047 static HRESULT WINAPI
IShellExecuteHookA_fnExecute(IShellExecuteHookA
* iface
, LPSHELLEXECUTEINFOA psei
)
1049 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
1051 SHELLEXECUTEINFOA sei_tmp
;
1052 PIDLCPanelStruct
* pcpanel
;
1053 char path
[MAX_PATH
];
1056 TRACE("(%p)->execute(%p)\n", This
, psei
);
1059 return E_INVALIDARG
;
1061 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
1064 return E_INVALIDARG
;
1067 lstrcpyA(path
+1, pcpanel
->szName
);
1069 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1070 lstrcatA(path
, "\" ");
1071 lstrcatA(path
, pcpanel
->szName
+pcpanel
->offsDispName
);
1073 memcpy(&sei_tmp
, psei
, sizeof(sei_tmp
));
1074 sei_tmp
.lpFile
= path
;
1075 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1077 ret
= ShellExecuteExA(&sei_tmp
);
1084 static IShellExecuteHookAVtbl vt_ShellExecuteHookA
=
1087 IShellExecuteHookA_fnQueryInterface
,
1088 IShellExecuteHookA_fnAddRef
,
1089 IShellExecuteHookA_fnRelease
,
1091 IShellExecuteHookA_fnExecute