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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
40 #include "shell32_main.h"
43 #include "wine/debug.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
49 /***********************************************************************
50 * control panel implementation in shell namespace
54 IShellFolder2 IShellFolder2_iface
;
55 IPersistFolder2 IPersistFolder2_iface
;
56 IShellExecuteHookW IShellExecuteHookW_iface
;
57 IShellExecuteHookA IShellExecuteHookA_iface
;
60 IUnknown
*pUnkOuter
; /* used for aggregation */
62 /* both paths are parsible from the desktop */
63 LPITEMIDLIST pidlRoot
; /* absolute pidl */
64 int dwAttributes
; /* attributes returned by GetAttributesOf FIXME: use it */
67 static const WCHAR name_spaceW
[] = L
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace";
69 static const IShellFolder2Vtbl vt_ShellFolder2
;
70 static const IPersistFolder2Vtbl vt_PersistFolder2
;
71 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW
;
72 static const IShellExecuteHookAVtbl vt_ShellExecuteHookA
;
74 static inline ICPanelImpl
*impl_from_IShellFolder2(IShellFolder2
*iface
)
76 return CONTAINING_RECORD(iface
, ICPanelImpl
, IShellFolder2_iface
);
79 static inline ICPanelImpl
*impl_from_IPersistFolder2(IPersistFolder2
*iface
)
81 return CONTAINING_RECORD(iface
, ICPanelImpl
, IPersistFolder2_iface
);
84 static inline ICPanelImpl
*impl_from_IShellExecuteHookW(IShellExecuteHookW
*iface
)
86 return CONTAINING_RECORD(iface
, ICPanelImpl
, IShellExecuteHookW_iface
);
89 static inline ICPanelImpl
*impl_from_IShellExecuteHookA(IShellExecuteHookA
*iface
)
91 return CONTAINING_RECORD(iface
, ICPanelImpl
, IShellExecuteHookA_iface
);
95 /***********************************************************************
96 * IShellFolder [ControlPanel] implementation
99 static const shvheader ControlPanelSFHeader
[] =
101 { &FMTID_Storage
, PID_STG_NAME
, IDS_SHV_COLUMN8
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15 },/*FIXME*/
102 { NULL
, 0, IDS_SHV_COLUMN9
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 80 },/*FIXME*/
105 #define CONROLPANELSHELLVIEWCOLUMNS 2
107 /**************************************************************************
108 * IControlPanel_Constructor
110 HRESULT WINAPI
IControlPanel_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
114 TRACE("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid(riid
));
118 if (pUnkOuter
&& !IsEqualIID (riid
, &IID_IUnknown
))
119 return CLASS_E_NOAGGREGATION
;
121 sf
= LocalAlloc(LMEM_ZEROINIT
, sizeof(ICPanelImpl
));
123 return E_OUTOFMEMORY
;
126 sf
->IShellFolder2_iface
.lpVtbl
= &vt_ShellFolder2
;
127 sf
->IPersistFolder2_iface
.lpVtbl
= &vt_PersistFolder2
;
128 sf
->IShellExecuteHookW_iface
.lpVtbl
= &vt_ShellExecuteHookW
;
129 sf
->IShellExecuteHookA_iface
.lpVtbl
= &vt_ShellExecuteHookA
;
130 sf
->pidlRoot
= _ILCreateControlPanel(); /* my qualified pidl */
131 sf
->pUnkOuter
= pUnkOuter
? pUnkOuter
: (IUnknown
*)&sf
->IShellFolder2_iface
;
133 if (FAILED(IShellFolder2_QueryInterface(&sf
->IShellFolder2_iface
, riid
, ppv
))) {
134 IShellFolder2_Release(&sf
->IShellFolder2_iface
);
135 return E_NOINTERFACE
;
137 IShellFolder2_Release(&sf
->IShellFolder2_iface
);
139 TRACE("--(%p)\n", sf
);
143 /**************************************************************************
144 * ISF_ControlPanel_fnQueryInterface
146 * NOTES supports not IPersist/IPersistFolder
148 static HRESULT WINAPI
ISF_ControlPanel_fnQueryInterface(IShellFolder2
*iface
, REFIID riid
,
151 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
153 TRACE("(%p)->(%s,%p)\n", This
, shdebugstr_guid(riid
), ppvObject
);
157 if (IsEqualIID(riid
, &IID_IUnknown
) ||
158 IsEqualIID(riid
, &IID_IShellFolder
) || IsEqualIID(riid
, &IID_IShellFolder2
))
159 *ppvObject
= &This
->IShellFolder2_iface
;
160 else if (IsEqualIID(riid
, &IID_IPersist
) ||
161 IsEqualIID(riid
, &IID_IPersistFolder
) || IsEqualIID(riid
, &IID_IPersistFolder2
))
162 *ppvObject
= &This
->IPersistFolder2_iface
;
163 else if (IsEqualIID(riid
, &IID_IShellExecuteHookW
))
164 *ppvObject
= &This
->IShellExecuteHookW_iface
;
165 else if (IsEqualIID(riid
, &IID_IShellExecuteHookA
))
166 *ppvObject
= &This
->IShellExecuteHookA_iface
;
169 IUnknown_AddRef((IUnknown
*)(*ppvObject
));
170 TRACE("-- Interface:(%p)->(%p)\n", ppvObject
, *ppvObject
);
173 TRACE("-- Interface: E_NOINTERFACE\n");
174 return E_NOINTERFACE
;
177 static ULONG WINAPI
ISF_ControlPanel_fnAddRef(IShellFolder2
*iface
)
179 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
180 ULONG refCount
= InterlockedIncrement(&This
->ref
);
182 TRACE("(%p)->(count=%lu)\n", This
, refCount
- 1);
187 static ULONG WINAPI
ISF_ControlPanel_fnRelease(IShellFolder2
*iface
)
189 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
190 ULONG refCount
= InterlockedDecrement(&This
->ref
);
192 TRACE("(%p)->(count=%lu)\n", This
, refCount
+ 1);
195 TRACE("-- destroying IShellFolder(%p)\n", This
);
196 SHFree(This
->pidlRoot
);
202 /**************************************************************************
203 * ISF_ControlPanel_fnParseDisplayName
205 static HRESULT WINAPI
ISF_ControlPanel_fnParseDisplayName(IShellFolder2
*iface
, HWND hwndOwner
,
206 LPBC pbc
, LPOLESTR lpszDisplayName
, DWORD
*pchEaten
, LPITEMIDLIST
*ppidl
,
207 DWORD
*pdwAttributes
)
209 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
211 HRESULT hr
= E_INVALIDARG
;
213 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
214 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
), pchEaten
, ppidl
, pdwAttributes
);
220 TRACE("(%p)->(-- ret=0x%08lx)\n", This
, hr
);
225 static LPITEMIDLIST
_ILCreateCPanelApplet(LPCSTR name
, LPCSTR displayName
,
226 LPCSTR comment
, int iconIdx
)
231 int size0
= (char*)tmp
.u
.cpanel
.szName
-(char*)&tmp
.u
.cpanel
;
235 tmp
.type
= PT_CPLAPPLET
;
236 tmp
.u
.cpanel
.dummy
= 0;
237 tmp
.u
.cpanel
.iconIdx
= iconIdx
;
242 tmp
.u
.cpanel
.offsDispName
= l
+1;
243 l
= strlen(displayName
);
246 tmp
.u
.cpanel
.offsComment
= tmp
.u
.cpanel
.offsDispName
+1+l
;
250 pidl
= SHAlloc(size
+4);
254 pidl
->mkid
.cb
= size
+2;
255 memcpy(pidl
->mkid
.abID
, &tmp
, 2+size0
);
257 p
= &((PIDLDATA
*)pidl
->mkid
.abID
)->u
.cpanel
;
258 memcpy(p
->szName
, name
, strlen(name
) + 1);
259 memcpy(p
->szName
+tmp
.u
.cpanel
.offsDispName
, displayName
, strlen(displayName
) + 1);
260 memcpy(p
->szName
+tmp
.u
.cpanel
.offsComment
, comment
, strlen(comment
) + 1);
262 *(WORD
*)((char*)pidl
+(size
+2)) = 0;
269 /**************************************************************************
270 * _ILGetCPanelPointer()
271 * gets a pointer to the control panel struct stored in the pidl
273 static PIDLCPanelStruct
* _ILGetCPanelPointer(LPCITEMIDLIST pidl
)
275 LPPIDLDATA pdata
= _ILGetDataPointer(pidl
);
277 if (pdata
&& pdata
->type
==PT_CPLAPPLET
)
278 return &pdata
->u
.cpanel
;
283 /**************************************************************************
284 * ISF_ControlPanel_fnEnumObjects
286 static BOOL
SHELL_RegisterCPanelApp(IEnumIDListImpl
*list
, LPCSTR path
)
295 char displayName
[MAX_PATH
];
296 char comment
[MAX_PATH
];
298 WCHAR wpath
[MAX_PATH
];
300 MultiByteToWideChar(CP_ACP
, 0, path
, -1, wpath
, MAX_PATH
);
302 list_init( &panel
.applets
);
303 applet
= Control_LoadApplet(0, wpath
, &panel
);
307 for(i
=0; i
<applet
->count
; ++i
)
309 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].name
, -1, displayName
, MAX_PATH
, 0, 0);
310 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].info
, -1, comment
, MAX_PATH
, 0, 0);
312 applet
->proc(0, CPL_INQUIRE
, i
, (LPARAM
)&info
);
315 iconIdx
= -info
.idIcon
; /* negative icon index instead of icon number */
319 pidl
= _ILCreateCPanelApplet(path
, displayName
, comment
, iconIdx
);
322 AddToEnumList(list
, pidl
);
324 Control_UnloadApplet(applet
);
329 static int SHELL_RegisterRegistryCPanelApps(IEnumIDListImpl
*list
, HKEY hkey_root
, LPCSTR szRepPath
)
332 char value
[MAX_PATH
];
337 if (RegOpenKeyA(hkey_root
, szRepPath
, &hkey
) == ERROR_SUCCESS
)
343 DWORD nameLen
= MAX_PATH
;
344 DWORD valueLen
= MAX_PATH
;
346 if (RegEnumValueA(hkey
, idx
, name
, &nameLen
, NULL
, NULL
, (LPBYTE
)value
, &valueLen
) != ERROR_SUCCESS
)
349 if (SHELL_RegisterCPanelApp(list
, value
))
358 static int SHELL_RegisterCPanelFolders(IEnumIDListImpl
*list
, HKEY hkey_root
, const WCHAR
*reg_path
)
365 if (RegOpenKeyW(hkey_root
, reg_path
, &hkey
) == ERROR_SUCCESS
)
370 if (RegEnumKeyA(hkey
, idx
, name
, MAX_PATH
) != ERROR_SUCCESS
)
375 LPITEMIDLIST pidl
= _ILCreateGuidFromStrA(name
);
377 if (pidl
&& AddToEnumList(list
, pidl
))
388 /**************************************************************************
389 * CreateCPanelEnumList()
391 static BOOL
CreateCPanelEnumList(IEnumIDListImpl
*list
, DWORD dwFlags
)
393 CHAR szPath
[MAX_PATH
];
394 WIN32_FIND_DATAA wfd
;
397 TRACE("(%p)->(flags=0x%08lx)\n", list
, dwFlags
);
399 /* enumerate control panel folders */
400 if (dwFlags
& SHCONTF_FOLDERS
)
401 SHELL_RegisterCPanelFolders(list
, HKEY_LOCAL_MACHINE
, name_spaceW
);
403 /* enumerate the control panel applets */
404 if (dwFlags
& SHCONTF_NONFOLDERS
)
408 GetSystemDirectoryA(szPath
, MAX_PATH
);
409 p
= PathAddBackslashA(szPath
);
412 TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n", list
, debugstr_a(szPath
));
413 hFile
= FindFirstFileA(szPath
, &wfd
);
415 if (hFile
!= INVALID_HANDLE_VALUE
)
419 if (!(dwFlags
& SHCONTF_INCLUDEHIDDEN
) && (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_HIDDEN
))
422 if (!(wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
423 strcpy(p
, wfd
.cFileName
);
424 SHELL_RegisterCPanelApp(list
, szPath
);
426 } while(FindNextFileA(hFile
, &wfd
));
430 SHELL_RegisterRegistryCPanelApps(list
, HKEY_LOCAL_MACHINE
,
431 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
432 SHELL_RegisterRegistryCPanelApps(list
, HKEY_CURRENT_USER
,
433 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
438 /**************************************************************************
439 * ISF_ControlPanel_fnEnumObjects
441 static HRESULT WINAPI
ISF_ControlPanel_fnEnumObjects(IShellFolder2
*iface
, HWND hwndOwner
,
442 DWORD dwFlags
, LPENUMIDLIST
*ppEnumIDList
)
444 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
445 IEnumIDListImpl
*list
;
447 TRACE("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This
, hwndOwner
, dwFlags
, ppEnumIDList
);
449 if (!(list
= IEnumIDList_Constructor()))
450 return E_OUTOFMEMORY
;
451 CreateCPanelEnumList(list
, dwFlags
);
452 *ppEnumIDList
= &list
->IEnumIDList_iface
;
454 TRACE("--(%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
459 /**************************************************************************
460 * ISF_ControlPanel_fnBindToObject
462 static HRESULT WINAPI
ISF_ControlPanel_fnBindToObject(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
463 LPBC pbcReserved
, REFIID riid
, void **ppvOut
)
465 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
467 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
469 return SHELL32_BindToChild(This
->pidlRoot
, &CLSID_ShellFSFolder
, NULL
, pidl
, riid
, ppvOut
);
472 /**************************************************************************
473 * ISF_ControlPanel_fnBindToStorage
475 static HRESULT WINAPI
ISF_ControlPanel_fnBindToStorage(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
476 LPBC pbcReserved
, REFIID riid
, void **ppvOut
)
478 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
480 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
486 /**************************************************************************
487 * ISF_ControlPanel_fnCompareIDs
490 static HRESULT WINAPI
ISF_ControlPanel_fnCompareIDs(IShellFolder2
*iface
, LPARAM lParam
,
491 LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
493 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
497 TRACE("(%p)->(0x%08Ix,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
498 nReturn
= SHELL32_CompareIDs(&This
->IShellFolder2_iface
, lParam
, pidl1
, pidl2
);
499 TRACE("-- %i\n", nReturn
);
503 /**************************************************************************
504 * ISF_ControlPanel_fnCreateViewObject
506 static HRESULT WINAPI
ISF_ControlPanel_fnCreateViewObject(IShellFolder2
*iface
, HWND hwndOwner
,
507 REFIID riid
, void **ppvOut
)
509 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
511 LPSHELLVIEW pShellView
;
512 HRESULT hr
= E_INVALIDARG
;
514 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This
, hwndOwner
, shdebugstr_guid(riid
), ppvOut
);
519 if (IsEqualIID(riid
, &IID_IDropTarget
)) {
520 WARN("IDropTarget not implemented\n");
522 } else if (IsEqualIID(riid
, &IID_IShellView
)) {
523 pShellView
= IShellView_Constructor((IShellFolder
*) iface
);
525 hr
= IShellView_QueryInterface(pShellView
, riid
, ppvOut
);
526 IShellView_Release(pShellView
);
529 FIXME("invalid/unsupported interface %s\n", shdebugstr_guid(riid
));
533 TRACE("--(%p)->(interface=%p)\n", This
, ppvOut
);
537 static BOOL
validate_name_space(const ITEMIDLIST
*pidl
)
544 if (!_ILIsPidlSimple(pidl
))
547 guid
= _ILGetGUIDPointer(pidl
);
550 if (StringFromCLSID(guid
, &guidW
) != S_OK
)
553 r
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, name_spaceW
, &hkey
);
554 if (r
== ERROR_SUCCESS
)
556 r
= RegOpenKeyW(hkey
, guidW
, &hitem
);
557 if (r
== ERROR_SUCCESS
)
561 CoTaskMemFree(guidW
);
562 return r
== ERROR_SUCCESS
;
565 /**************************************************************************
566 * ISF_ControlPanel_fnGetAttributesOf
568 static HRESULT WINAPI
ISF_ControlPanel_fnGetAttributesOf(IShellFolder2
*iface
, UINT cidl
,
569 LPCITEMIDLIST
*apidl
, DWORD
*rgfInOut
)
571 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
575 TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08lx))\n",
576 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
586 while(cidl
> 0 && *apidl
) {
589 /* TODO: panel with GUID can contain sub-items but we don't support it yet */
590 if (!(*rgfInOut
& SFGAO_VALIDATE
) || _ILGetCPanelPointer(*apidl
)
591 || validate_name_space(*apidl
))
592 *rgfInOut
&= SFGAO_CANLINK
;
594 *rgfInOut
&= SFGAO_VALIDATE
;
600 TRACE("-- result=0x%08lx\n", *rgfInOut
);
604 /**************************************************************************
605 * ISF_ControlPanel_fnGetUIObjectOf
608 * HWND hwndOwner, //[in ] Parent window for any output
609 * UINT cidl, //[in ] array size
610 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
611 * REFIID riid, //[in ] Requested Interface
612 * UINT* prgfInOut, //[ ] reserved
613 * LPVOID* ppvObject) //[out] Resulting Interface
616 static HRESULT WINAPI
ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2
*iface
, HWND hwndOwner
,
617 UINT cidl
, LPCITEMIDLIST
*apidl
, REFIID riid
, UINT
*prgfInOut
, void **ppvOut
)
619 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
622 IUnknown
*pObj
= NULL
;
623 HRESULT hr
= E_INVALIDARG
;
625 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
626 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid(riid
), prgfInOut
, ppvOut
);
631 if (IsEqualIID(riid
, &IID_IContextMenu
) &&(cidl
>= 1)) {
632 return ItemMenu_Constructor((IShellFolder
*)iface
, This
->pidlRoot
, apidl
, cidl
, riid
, ppvOut
);
633 } else if (IsEqualIID(riid
, &IID_IDataObject
) &&(cidl
>= 1)) {
634 pObj
= (LPUNKNOWN
) IDataObject_Constructor(hwndOwner
, This
->pidlRoot
, apidl
, cidl
);
636 } else if (IsEqualIID(riid
, &IID_IExtractIconA
) &&(cidl
== 1)) {
637 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
638 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor(pidl
);
641 } else if (IsEqualIID(riid
, &IID_IExtractIconW
) &&(cidl
== 1)) {
642 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
643 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor(pidl
);
646 } else if ((IsEqualIID(riid
,&IID_IShellLinkW
) || IsEqualIID(riid
,&IID_IShellLinkA
))
648 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
649 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
, &pObj
);
655 if (SUCCEEDED(hr
) && !pObj
)
660 TRACE("(%p)->hr=0x%08lx\n", This
, hr
);
664 /**************************************************************************
665 * ISF_ControlPanel_fnGetDisplayNameOf
667 static HRESULT WINAPI
ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
668 DWORD dwFlags
, LPSTRRET strRet
)
670 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
672 CHAR szPath
[MAX_PATH
];
673 WCHAR wszPath
[MAX_PATH
+1]; /* +1 for potential backslash */
674 PIDLCPanelStruct
* pcpanel
;
678 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n", This
, pidl
, dwFlags
, strRet
);
681 if (!pidl
|| !strRet
)
684 pcpanel
= _ILGetCPanelPointer(pidl
);
687 lstrcpyA(szPath
, pcpanel
->szName
+pcpanel
->offsDispName
);
689 if (!(dwFlags
& SHGDN_FORPARSING
))
690 FIXME("retrieve display name from control panel app\n");
692 /* take names of special folders only if it's only this folder */
693 else if (_ILIsSpecialFolder(pidl
)) {
694 BOOL bSimplePidl
= _ILIsPidlSimple(pidl
);
697 _ILSimpleGetTextW(pidl
, wszPath
, MAX_PATH
); /* append my own path */
699 FIXME("special pidl\n");
702 if ((dwFlags
& SHGDN_FORPARSING
) && !bSimplePidl
) { /* go deeper if needed */
705 PathAddBackslashW(wszPath
);
706 len
= lstrlenW(wszPath
);
708 if (FAILED(SHELL32_GetDisplayNameOfChild(iface
, pidl
, dwFlags
| SHGDN_INFOLDER
, wszPath
+ len
, MAX_PATH
+ 1 - len
)))
709 return E_OUTOFMEMORY
;
710 if (!WideCharToMultiByte(CP_ACP
, 0, wszPath
, -1, szPath
, MAX_PATH
, NULL
, NULL
))
715 strRet
->uType
= STRRET_CSTR
;
716 lstrcpynA(strRet
->cStr
, szPath
, MAX_PATH
);
718 TRACE("--(%p)->(%s)\n", This
, szPath
);
722 /**************************************************************************
723 * ISF_ControlPanel_fnSetNameOf
724 * Changes the name of a file object or subfolder, possibly changing its item
725 * identifier in the process.
728 * HWND hwndOwner, //[in ] Owner window for output
729 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
730 * LPCOLESTR lpszName, //[in ] the items new display name
731 * DWORD dwFlags, //[in ] SHGNO formatting flags
732 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
734 static HRESULT WINAPI
ISF_ControlPanel_fnSetNameOf(IShellFolder2
*iface
, HWND hwndOwner
,
735 LPCITEMIDLIST pidl
, LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
*pPidlOut
)
737 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
738 FIXME("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This
, hwndOwner
, pidl
, debugstr_w(lpName
), dwFlags
, pPidlOut
);
742 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2
*iface
, GUID
*guid
)
744 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
745 TRACE("(%p)->(%p)\n", This
, guid
);
749 static HRESULT WINAPI
ISF_ControlPanel_fnEnumSearches(IShellFolder2
*iface
,
750 IEnumExtraSearch
**ppenum
)
752 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
753 FIXME("(%p)\n", This
);
757 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2
*iface
, DWORD reserved
,
758 ULONG
*sort
, ULONG
*display
)
760 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
762 TRACE("(%p)->(%#lx %p %p)\n", This
, reserved
, sort
, display
);
767 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2
*iface
, UINT iColumn
,
770 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
772 TRACE("(%p)\n", This
);
774 if (!pcsFlags
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
) return E_INVALIDARG
;
775 *pcsFlags
= ControlPanelSFHeader
[iColumn
].pcsFlags
;
778 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsEx(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
779 const SHCOLUMNID
*pscid
, VARIANT
*pv
)
781 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
782 FIXME("(%p)\n", This
);
786 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsOf(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
787 UINT iColumn
, SHELLDETAILS
*psd
)
789 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
790 PIDLCPanelStruct
* pcpanel
;
792 TRACE("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
794 if (!psd
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
)
798 return SHELL32_GetColumnDetails(ControlPanelSFHeader
, iColumn
, psd
);
800 psd
->str
.cStr
[0] = 0x00;
801 psd
->str
.uType
= STRRET_CSTR
;
804 case 1: /* comment */
805 pcpanel
= _ILGetCPanelPointer(pidl
);
808 lstrcpyA(psd
->str
.cStr
, pcpanel
->szName
+pcpanel
->offsComment
);
810 _ILGetFileType(pidl
, psd
->str
.cStr
, MAX_PATH
);
814 return shellfolder_get_file_details( iface
, pidl
, ControlPanelSFHeader
, iColumn
, psd
);
818 static HRESULT WINAPI
ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2
*iface
, UINT column
,
821 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
822 FIXME("(%p)\n", This
);
826 static const IShellFolder2Vtbl vt_ShellFolder2
=
829 ISF_ControlPanel_fnQueryInterface
,
830 ISF_ControlPanel_fnAddRef
,
831 ISF_ControlPanel_fnRelease
,
832 ISF_ControlPanel_fnParseDisplayName
,
833 ISF_ControlPanel_fnEnumObjects
,
834 ISF_ControlPanel_fnBindToObject
,
835 ISF_ControlPanel_fnBindToStorage
,
836 ISF_ControlPanel_fnCompareIDs
,
837 ISF_ControlPanel_fnCreateViewObject
,
838 ISF_ControlPanel_fnGetAttributesOf
,
839 ISF_ControlPanel_fnGetUIObjectOf
,
840 ISF_ControlPanel_fnGetDisplayNameOf
,
841 ISF_ControlPanel_fnSetNameOf
,
844 ISF_ControlPanel_fnGetDefaultSearchGUID
,
845 ISF_ControlPanel_fnEnumSearches
,
846 ISF_ControlPanel_fnGetDefaultColumn
,
847 ISF_ControlPanel_fnGetDefaultColumnState
,
848 ISF_ControlPanel_fnGetDetailsEx
,
849 ISF_ControlPanel_fnGetDetailsOf
,
850 ISF_ControlPanel_fnMapColumnToSCID
853 /************************************************************************
854 * ICPanel_PersistFolder2_QueryInterface
856 static HRESULT WINAPI
ICPanel_PersistFolder2_QueryInterface(IPersistFolder2
* iface
, REFIID iid
, LPVOID
* ppvObject
)
858 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
860 TRACE("(%p)\n", This
);
862 return IShellFolder2_QueryInterface(&This
->IShellFolder2_iface
, iid
, ppvObject
);
865 /************************************************************************
866 * ICPanel_PersistFolder2_AddRef
868 static ULONG WINAPI
ICPanel_PersistFolder2_AddRef(IPersistFolder2
* iface
)
870 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
872 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
874 return IShellFolder2_AddRef(&This
->IShellFolder2_iface
);
877 /************************************************************************
878 * ISFPersistFolder_Release
880 static ULONG WINAPI
ICPanel_PersistFolder2_Release(IPersistFolder2
* iface
)
882 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
884 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
886 return IShellFolder2_Release(&This
->IShellFolder2_iface
);
889 /************************************************************************
890 * ICPanel_PersistFolder2_GetClassID
892 static HRESULT WINAPI
ICPanel_PersistFolder2_GetClassID(IPersistFolder2
* iface
, CLSID
* lpClassId
)
894 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
896 TRACE("(%p)\n", This
);
900 *lpClassId
= CLSID_ControlPanel
;
905 /************************************************************************
906 * ICPanel_PersistFolder2_Initialize
908 * NOTES: it makes no sense to change the pidl
910 static HRESULT WINAPI
ICPanel_PersistFolder2_Initialize(IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
912 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
913 TRACE("(%p)->(%p)\n", This
, pidl
);
917 /**************************************************************************
918 * IPersistFolder2_fnGetCurFolder
920 static HRESULT WINAPI
ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2
* iface
, LPITEMIDLIST
* pidl
)
922 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
924 TRACE("(%p)->(%p)\n", This
, pidl
);
928 *pidl
= ILClone(This
->pidlRoot
);
932 static const IPersistFolder2Vtbl vt_PersistFolder2
=
935 ICPanel_PersistFolder2_QueryInterface
,
936 ICPanel_PersistFolder2_AddRef
,
937 ICPanel_PersistFolder2_Release
,
938 ICPanel_PersistFolder2_GetClassID
,
939 ICPanel_PersistFolder2_Initialize
,
940 ICPanel_PersistFolder2_GetCurFolder
943 HRESULT
CPanel_GetIconLocationW(LPCITEMIDLIST pidl
,
944 LPWSTR szIconFile
, UINT cchMax
, int* piIndex
)
946 PIDLCPanelStruct
* pcpanel
= _ILGetCPanelPointer(pidl
);
951 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, szIconFile
, cchMax
);
952 *piIndex
= pcpanel
->iconIdx
!=-1? pcpanel
->iconIdx
: 0;
958 /**************************************************************************
959 * IShellExecuteHookW Implementation
962 static HRESULT WINAPI
IShellExecuteHookW_fnQueryInterface(
963 IShellExecuteHookW
* iface
, REFIID riid
, void** ppvObject
)
965 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
967 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
969 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
972 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnAddRef(IShellExecuteHookW
* iface
)
974 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
976 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
978 return IUnknown_AddRef(This
->pUnkOuter
);
981 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnRelease(IShellExecuteHookW
* iface
)
983 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
985 TRACE("(%p)\n", This
);
987 return IUnknown_Release(This
->pUnkOuter
);
990 static HRESULT WINAPI
IShellExecuteHookW_fnExecute(IShellExecuteHookW
*iface
,
991 LPSHELLEXECUTEINFOW psei
)
993 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
994 SHELLEXECUTEINFOW sei_tmp
;
995 PIDLCPanelStruct
* pcpanel
;
996 WCHAR path
[MAX_PATH
];
997 WCHAR params
[MAX_PATH
];
1001 TRACE("(%p)->execute(%p)\n", This
, psei
);
1004 return E_INVALIDARG
;
1006 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
1009 return E_INVALIDARG
;
1012 /* Return value from MultiByteToWideChar includes terminating NUL, which
1013 * compensates for the starting double quote we just put in */
1014 l
= MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, path
+1, MAX_PATH
-1);
1016 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1020 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
+pcpanel
->offsDispName
, -1, params
, MAX_PATH
);
1023 sei_tmp
.lpFile
= path
;
1024 sei_tmp
.lpParameters
= params
;
1025 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1026 sei_tmp
.lpVerb
= L
"cplopen";
1028 ret
= ShellExecuteExW(&sei_tmp
);
1035 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW
=
1038 IShellExecuteHookW_fnQueryInterface
,
1039 IShellExecuteHookW_fnAddRef
,
1040 IShellExecuteHookW_fnRelease
,
1042 IShellExecuteHookW_fnExecute
1046 /**************************************************************************
1047 * IShellExecuteHookA Implementation
1050 static HRESULT WINAPI
IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA
* iface
, REFIID riid
, void** ppvObject
)
1052 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1054 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
1056 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
1059 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnAddRef(IShellExecuteHookA
* iface
)
1061 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1063 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
1065 return IUnknown_AddRef(This
->pUnkOuter
);
1068 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnRelease(IShellExecuteHookA
* iface
)
1070 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1072 TRACE("(%p)\n", This
);
1074 return IUnknown_Release(This
->pUnkOuter
);
1077 static HRESULT WINAPI
IShellExecuteHookA_fnExecute(IShellExecuteHookA
*iface
,
1078 LPSHELLEXECUTEINFOA psei
)
1080 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1082 SHELLEXECUTEINFOA sei_tmp
;
1083 PIDLCPanelStruct
* pcpanel
;
1084 char path
[MAX_PATH
];
1087 TRACE("(%p)->execute(%p)\n", This
, psei
);
1090 return E_INVALIDARG
;
1092 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
1095 return E_INVALIDARG
;
1098 memcpy(path
+1, pcpanel
->szName
, strlen(pcpanel
->szName
) + 1);
1100 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1101 lstrcatA(path
, "\" ");
1102 lstrcatA(path
, pcpanel
->szName
+pcpanel
->offsDispName
);
1105 sei_tmp
.lpFile
= path
;
1106 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1108 ret
= ShellExecuteExA(&sei_tmp
);
1115 static const IShellExecuteHookAVtbl vt_ShellExecuteHookA
=
1117 IShellExecuteHookA_fnQueryInterface
,
1118 IShellExecuteHookA_fnAddRef
,
1119 IShellExecuteHookA_fnRelease
,
1120 IShellExecuteHookA_fnExecute