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
22 #include "wine/port.h"
30 #define NONAMELESSUNION
31 #define NONAMELESSSTRUCT
46 #include "undocshell.h"
47 #include "shell32_main.h"
50 #include "wine/debug.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
56 /***********************************************************************
57 * control panel implementation in shell namespace
61 IShellFolder2 IShellFolder2_iface
;
62 IPersistFolder2 IPersistFolder2_iface
;
63 IShellExecuteHookW IShellExecuteHookW_iface
;
64 IShellExecuteHookA IShellExecuteHookA_iface
;
67 IUnknown
*pUnkOuter
; /* used for aggregation */
69 /* both paths are parsible from the desktop */
70 LPITEMIDLIST pidlRoot
; /* absolute pidl */
71 int dwAttributes
; /* attributes returned by GetAttributesOf FIXME: use it */
74 static const IShellFolder2Vtbl vt_ShellFolder2
;
75 static const IPersistFolder2Vtbl vt_PersistFolder2
;
76 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW
;
77 static const IShellExecuteHookAVtbl vt_ShellExecuteHookA
;
79 static inline ICPanelImpl
*impl_from_IShellFolder2(IShellFolder2
*iface
)
81 return CONTAINING_RECORD(iface
, ICPanelImpl
, IShellFolder2_iface
);
84 static inline ICPanelImpl
*impl_from_IPersistFolder2(IPersistFolder2
*iface
)
86 return CONTAINING_RECORD(iface
, ICPanelImpl
, IPersistFolder2_iface
);
89 static inline ICPanelImpl
*impl_from_IShellExecuteHookW(IShellExecuteHookW
*iface
)
91 return CONTAINING_RECORD(iface
, ICPanelImpl
, IShellExecuteHookW_iface
);
94 static inline ICPanelImpl
*impl_from_IShellExecuteHookA(IShellExecuteHookA
*iface
)
96 return CONTAINING_RECORD(iface
, ICPanelImpl
, IShellExecuteHookA_iface
);
100 /***********************************************************************
101 * IShellFolder [ControlPanel] implementation
104 static const shvheader ControlPanelSFHeader
[] = {
105 {IDS_SHV_COLUMN8
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},/*FIXME*/
106 {IDS_SHV_COLUMN9
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_LEFT
, 80},/*FIXME*/
109 #define CONROLPANELSHELLVIEWCOLUMNS 2
111 /**************************************************************************
112 * IControlPanel_Constructor
114 HRESULT WINAPI
IControlPanel_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
118 TRACE("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid(riid
));
122 if (pUnkOuter
&& !IsEqualIID (riid
, &IID_IUnknown
))
123 return CLASS_E_NOAGGREGATION
;
125 sf
= LocalAlloc(LMEM_ZEROINIT
, sizeof(ICPanelImpl
));
127 return E_OUTOFMEMORY
;
130 sf
->IShellFolder2_iface
.lpVtbl
= &vt_ShellFolder2
;
131 sf
->IPersistFolder2_iface
.lpVtbl
= &vt_PersistFolder2
;
132 sf
->IShellExecuteHookW_iface
.lpVtbl
= &vt_ShellExecuteHookW
;
133 sf
->IShellExecuteHookA_iface
.lpVtbl
= &vt_ShellExecuteHookA
;
134 sf
->pidlRoot
= _ILCreateControlPanel(); /* my qualified pidl */
135 sf
->pUnkOuter
= pUnkOuter
? pUnkOuter
: (IUnknown
*)&sf
->IShellFolder2_iface
;
137 if (FAILED(IShellFolder2_QueryInterface(&sf
->IShellFolder2_iface
, riid
, ppv
))) {
138 IShellFolder2_Release(&sf
->IShellFolder2_iface
);
139 return E_NOINTERFACE
;
142 TRACE("--(%p)\n", sf
);
146 /**************************************************************************
147 * ISF_ControlPanel_fnQueryInterface
149 * NOTES supports not IPersist/IPersistFolder
151 static HRESULT WINAPI
ISF_ControlPanel_fnQueryInterface(IShellFolder2
*iface
, REFIID riid
,
154 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
156 TRACE("(%p)->(%s,%p)\n", This
, shdebugstr_guid(riid
), ppvObject
);
160 if (IsEqualIID(riid
, &IID_IUnknown
) ||
161 IsEqualIID(riid
, &IID_IShellFolder
) || IsEqualIID(riid
, &IID_IShellFolder2
))
163 else if (IsEqualIID(riid
, &IID_IPersist
) ||
164 IsEqualIID(riid
, &IID_IPersistFolder
) || IsEqualIID(riid
, &IID_IPersistFolder2
))
165 *ppvObject
= &This
->IPersistFolder2_iface
;
166 else if (IsEqualIID(riid
, &IID_IShellExecuteHookW
))
167 *ppvObject
= &This
->IShellExecuteHookW_iface
;
168 else if (IsEqualIID(riid
, &IID_IShellExecuteHookA
))
169 *ppvObject
= &This
->IShellExecuteHookA_iface
;
172 IUnknown_AddRef((IUnknown
*)(*ppvObject
));
173 TRACE("-- Interface:(%p)->(%p)\n", ppvObject
, *ppvObject
);
176 TRACE("-- Interface: E_NOINTERFACE\n");
177 return E_NOINTERFACE
;
180 static ULONG WINAPI
ISF_ControlPanel_fnAddRef(IShellFolder2
*iface
)
182 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
183 ULONG refCount
= InterlockedIncrement(&This
->ref
);
185 TRACE("(%p)->(count=%u)\n", This
, refCount
- 1);
190 static ULONG WINAPI
ISF_ControlPanel_fnRelease(IShellFolder2
*iface
)
192 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
193 ULONG refCount
= InterlockedDecrement(&This
->ref
);
195 TRACE("(%p)->(count=%u)\n", This
, refCount
+ 1);
198 TRACE("-- destroying IShellFolder(%p)\n", This
);
199 SHFree(This
->pidlRoot
);
205 /**************************************************************************
206 * ISF_ControlPanel_fnParseDisplayName
208 static HRESULT WINAPI
ISF_ControlPanel_fnParseDisplayName(IShellFolder2
*iface
, HWND hwndOwner
,
209 LPBC pbc
, LPOLESTR lpszDisplayName
, DWORD
*pchEaten
, LPITEMIDLIST
*ppidl
,
210 DWORD
*pdwAttributes
)
212 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
214 HRESULT hr
= E_INVALIDARG
;
216 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
217 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
), pchEaten
, ppidl
, pdwAttributes
);
223 TRACE("(%p)->(-- ret=0x%08x)\n", This
, hr
);
228 static LPITEMIDLIST
_ILCreateCPanelApplet(LPCSTR name
, LPCSTR displayName
,
229 LPCSTR comment
, int iconIdx
)
234 int size0
= (char*)tmp
.u
.cpanel
.szName
-(char*)&tmp
.u
.cpanel
;
238 tmp
.type
= PT_CPLAPPLET
;
239 tmp
.u
.cpanel
.dummy
= 0;
240 tmp
.u
.cpanel
.iconIdx
= iconIdx
;
245 tmp
.u
.cpanel
.offsDispName
= l
+1;
246 l
= strlen(displayName
);
249 tmp
.u
.cpanel
.offsComment
= tmp
.u
.cpanel
.offsDispName
+1+l
;
253 pidl
= SHAlloc(size
+4);
257 pidl
->mkid
.cb
= size
+2;
258 memcpy(pidl
->mkid
.abID
, &tmp
, 2+size0
);
260 p
= &((PIDLDATA
*)pidl
->mkid
.abID
)->u
.cpanel
;
261 strcpy(p
->szName
, name
);
262 strcpy(p
->szName
+tmp
.u
.cpanel
.offsDispName
, displayName
);
263 strcpy(p
->szName
+tmp
.u
.cpanel
.offsComment
, comment
);
265 *(WORD
*)((char*)pidl
+(size
+2)) = 0;
272 /**************************************************************************
273 * _ILGetCPanelPointer()
274 * gets a pointer to the control panel struct stored in the pidl
276 static PIDLCPanelStruct
* _ILGetCPanelPointer(LPCITEMIDLIST pidl
)
278 LPPIDLDATA pdata
= _ILGetDataPointer(pidl
);
280 if (pdata
&& pdata
->type
==PT_CPLAPPLET
)
281 return &pdata
->u
.cpanel
;
286 /**************************************************************************
287 * ISF_ControlPanel_fnEnumObjects
289 static BOOL
SHELL_RegisterCPanelApp(IEnumIDListImpl
*list
, LPCSTR path
)
298 char displayName
[MAX_PATH
];
299 char comment
[MAX_PATH
];
301 WCHAR wpath
[MAX_PATH
];
303 MultiByteToWideChar(CP_ACP
, 0, path
, -1, wpath
, MAX_PATH
);
306 applet
= Control_LoadApplet(0, wpath
, &panel
);
310 for(i
=0; i
<applet
->count
; ++i
)
312 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].szName
, -1, displayName
, MAX_PATH
, 0, 0);
313 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].szInfo
, -1, comment
, MAX_PATH
, 0, 0);
315 applet
->proc(0, CPL_INQUIRE
, i
, (LPARAM
)&info
);
318 iconIdx
= -info
.idIcon
; /* negative icon index instead of icon number */
322 pidl
= _ILCreateCPanelApplet(path
, displayName
, comment
, iconIdx
);
325 AddToEnumList(list
, pidl
);
327 Control_UnloadApplet(applet
);
332 static int SHELL_RegisterRegistryCPanelApps(IEnumIDListImpl
*list
, HKEY hkey_root
, LPCSTR szRepPath
)
335 char value
[MAX_PATH
];
340 if (RegOpenKeyA(hkey_root
, szRepPath
, &hkey
) == ERROR_SUCCESS
)
346 DWORD nameLen
= MAX_PATH
;
347 DWORD valueLen
= MAX_PATH
;
349 if (RegEnumValueA(hkey
, idx
, name
, &nameLen
, NULL
, NULL
, (LPBYTE
)value
, &valueLen
) != ERROR_SUCCESS
)
352 if (SHELL_RegisterCPanelApp(list
, value
))
361 static int SHELL_RegisterCPanelFolders(IEnumIDListImpl
*list
, HKEY hkey_root
, LPCSTR szRepPath
)
368 if (RegOpenKeyA(hkey_root
, szRepPath
, &hkey
) == ERROR_SUCCESS
)
373 if (RegEnumKeyA(hkey
, idx
, name
, MAX_PATH
) != ERROR_SUCCESS
)
378 LPITEMIDLIST pidl
= _ILCreateGuidFromStrA(name
);
380 if (pidl
&& AddToEnumList(list
, pidl
))
391 /**************************************************************************
392 * CreateCPanelEnumList()
394 static BOOL
CreateCPanelEnumList(IEnumIDListImpl
*list
, DWORD dwFlags
)
396 CHAR szPath
[MAX_PATH
];
397 WIN32_FIND_DATAA wfd
;
400 TRACE("(%p)->(flags=0x%08x)\n", list
, dwFlags
);
402 /* enumerate control panel folders */
403 if (dwFlags
& SHCONTF_FOLDERS
)
404 SHELL_RegisterCPanelFolders(list
, HKEY_LOCAL_MACHINE
,
405 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
407 /* enumerate the control panel applets */
408 if (dwFlags
& SHCONTF_NONFOLDERS
)
412 GetSystemDirectoryA(szPath
, MAX_PATH
);
413 p
= PathAddBackslashA(szPath
);
416 TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n", list
, debugstr_a(szPath
));
417 hFile
= FindFirstFileA(szPath
, &wfd
);
419 if (hFile
!= INVALID_HANDLE_VALUE
)
423 if (!(dwFlags
& SHCONTF_INCLUDEHIDDEN
) && (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_HIDDEN
))
426 if (!(wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
427 strcpy(p
, wfd
.cFileName
);
428 SHELL_RegisterCPanelApp(list
, szPath
);
430 } while(FindNextFileA(hFile
, &wfd
));
434 SHELL_RegisterRegistryCPanelApps(list
, HKEY_LOCAL_MACHINE
,
435 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
436 SHELL_RegisterRegistryCPanelApps(list
, HKEY_CURRENT_USER
,
437 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
442 /**************************************************************************
443 * ISF_ControlPanel_fnEnumObjects
445 static HRESULT WINAPI
ISF_ControlPanel_fnEnumObjects(IShellFolder2
*iface
, HWND hwndOwner
,
446 DWORD dwFlags
, LPENUMIDLIST
*ppEnumIDList
)
448 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
449 IEnumIDListImpl
*list
;
451 TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This
, hwndOwner
, dwFlags
, ppEnumIDList
);
453 if (!(list
= IEnumIDList_Constructor()))
454 return E_OUTOFMEMORY
;
455 CreateCPanelEnumList(list
, dwFlags
);
456 *ppEnumIDList
= &list
->IEnumIDList_iface
;
458 TRACE("--(%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
463 /**************************************************************************
464 * ISF_ControlPanel_fnBindToObject
466 static HRESULT WINAPI
ISF_ControlPanel_fnBindToObject(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
467 LPBC pbcReserved
, REFIID riid
, void **ppvOut
)
469 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
471 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
473 return SHELL32_BindToChild(This
->pidlRoot
, NULL
, pidl
, riid
, ppvOut
);
476 /**************************************************************************
477 * ISF_ControlPanel_fnBindToStorage
479 static HRESULT WINAPI
ISF_ControlPanel_fnBindToStorage(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
480 LPBC pbcReserved
, REFIID riid
, void **ppvOut
)
482 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
484 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
490 /**************************************************************************
491 * ISF_ControlPanel_fnCompareIDs
494 static HRESULT WINAPI
ISF_ControlPanel_fnCompareIDs(IShellFolder2
*iface
, LPARAM lParam
,
495 LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
497 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
501 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
502 nReturn
= SHELL32_CompareIDs((IShellFolder
*)&This
->IShellFolder2_iface
, lParam
, pidl1
, pidl2
);
503 TRACE("-- %i\n", nReturn
);
507 /**************************************************************************
508 * ISF_ControlPanel_fnCreateViewObject
510 static HRESULT WINAPI
ISF_ControlPanel_fnCreateViewObject(IShellFolder2
*iface
, HWND hwndOwner
,
511 REFIID riid
, void **ppvOut
)
513 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
515 LPSHELLVIEW pShellView
;
516 HRESULT hr
= E_INVALIDARG
;
518 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This
, hwndOwner
, shdebugstr_guid(riid
), ppvOut
);
523 if (IsEqualIID(riid
, &IID_IDropTarget
)) {
524 WARN("IDropTarget not implemented\n");
526 } else if (IsEqualIID(riid
, &IID_IContextMenu
)) {
527 WARN("IContextMenu not implemented\n");
529 } else if (IsEqualIID(riid
, &IID_IShellView
)) {
530 pShellView
= IShellView_Constructor((IShellFolder
*) iface
);
532 hr
= IShellView_QueryInterface(pShellView
, riid
, ppvOut
);
533 IShellView_Release(pShellView
);
537 TRACE("--(%p)->(interface=%p)\n", This
, ppvOut
);
541 /**************************************************************************
542 * ISF_ControlPanel_fnGetAttributesOf
544 static HRESULT WINAPI
ISF_ControlPanel_fnGetAttributesOf(IShellFolder2
*iface
, UINT cidl
,
545 LPCITEMIDLIST
*apidl
, DWORD
*rgfInOut
)
547 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
551 TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
552 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
562 while(cidl
> 0 && *apidl
) {
564 SHELL32_GetItemAttributes((IShellFolder
*)&This
->IShellFolder2_iface
, *apidl
, rgfInOut
);
568 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
569 *rgfInOut
&= ~SFGAO_VALIDATE
;
571 TRACE("-- result=0x%08x\n", *rgfInOut
);
575 /**************************************************************************
576 * ISF_ControlPanel_fnGetUIObjectOf
579 * HWND hwndOwner, //[in ] Parent window for any output
580 * UINT cidl, //[in ] array size
581 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
582 * REFIID riid, //[in ] Requested Interface
583 * UINT* prgfInOut, //[ ] reserved
584 * LPVOID* ppvObject) //[out] Resulting Interface
587 static HRESULT WINAPI
ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2
*iface
, HWND hwndOwner
,
588 UINT cidl
, LPCITEMIDLIST
*apidl
, REFIID riid
, UINT
*prgfInOut
, void **ppvOut
)
590 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
593 IUnknown
*pObj
= NULL
;
594 HRESULT hr
= E_INVALIDARG
;
596 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
597 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid(riid
), prgfInOut
, ppvOut
);
602 if (IsEqualIID(riid
, &IID_IContextMenu
) &&(cidl
>= 1)) {
603 pObj
= (LPUNKNOWN
) ISvItemCm_Constructor((IShellFolder
*) iface
, This
->pidlRoot
, apidl
, cidl
);
605 } else if (IsEqualIID(riid
, &IID_IDataObject
) &&(cidl
>= 1)) {
606 pObj
= (LPUNKNOWN
) IDataObject_Constructor(hwndOwner
, This
->pidlRoot
, apidl
, cidl
);
608 } else if (IsEqualIID(riid
, &IID_IExtractIconA
) &&(cidl
== 1)) {
609 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
610 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor(pidl
);
613 } else if (IsEqualIID(riid
, &IID_IExtractIconW
) &&(cidl
== 1)) {
614 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
615 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor(pidl
);
618 } else if ((IsEqualIID(riid
,&IID_IShellLinkW
) || IsEqualIID(riid
,&IID_IShellLinkA
))
620 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
621 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
,(LPVOID
*)&pObj
);
627 if (SUCCEEDED(hr
) && !pObj
)
632 TRACE("(%p)->hr=0x%08x\n", This
, hr
);
636 /**************************************************************************
637 * ISF_ControlPanel_fnGetDisplayNameOf
639 static HRESULT WINAPI
ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
640 DWORD dwFlags
, LPSTRRET strRet
)
642 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
644 CHAR szPath
[MAX_PATH
];
645 WCHAR wszPath
[MAX_PATH
+1]; /* +1 for potential backslash */
646 PIDLCPanelStruct
* pcpanel
;
650 TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", This
, pidl
, dwFlags
, strRet
);
653 if (!pidl
|| !strRet
)
656 pcpanel
= _ILGetCPanelPointer(pidl
);
659 lstrcpyA(szPath
, pcpanel
->szName
+pcpanel
->offsDispName
);
661 if (!(dwFlags
& SHGDN_FORPARSING
))
662 FIXME("retrieve display name from control panel app\n");
664 /* take names of special folders only if it's only this folder */
665 else if (_ILIsSpecialFolder(pidl
)) {
666 BOOL bSimplePidl
= _ILIsPidlSimple(pidl
);
669 _ILSimpleGetTextW(pidl
, wszPath
, MAX_PATH
); /* append my own path */
671 FIXME("special pidl\n");
674 if ((dwFlags
& SHGDN_FORPARSING
) && !bSimplePidl
) { /* go deeper if needed */
677 PathAddBackslashW(wszPath
);
678 len
= lstrlenW(wszPath
);
680 if (FAILED(SHELL32_GetDisplayNameOfChild(iface
, pidl
, dwFlags
| SHGDN_INFOLDER
, wszPath
+ len
, MAX_PATH
+ 1 - len
)))
681 return E_OUTOFMEMORY
;
682 if (!WideCharToMultiByte(CP_ACP
, 0, wszPath
, -1, szPath
, MAX_PATH
, NULL
, NULL
))
687 strRet
->uType
= STRRET_CSTR
;
688 lstrcpynA(strRet
->u
.cStr
, szPath
, MAX_PATH
);
690 TRACE("--(%p)->(%s)\n", This
, szPath
);
694 /**************************************************************************
695 * ISF_ControlPanel_fnSetNameOf
696 * Changes the name of a file object or subfolder, possibly changing its item
697 * identifier in the process.
700 * HWND hwndOwner, //[in ] Owner window for output
701 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
702 * LPCOLESTR lpszName, //[in ] the items new display name
703 * DWORD dwFlags, //[in ] SHGNO formatting flags
704 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
706 static HRESULT WINAPI
ISF_ControlPanel_fnSetNameOf(IShellFolder2
*iface
, HWND hwndOwner
,
707 LPCITEMIDLIST pidl
, LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
*pPidlOut
)
709 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
710 FIXME("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This
, hwndOwner
, pidl
, debugstr_w(lpName
), dwFlags
, pPidlOut
);
714 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2
*iface
, GUID
*pguid
)
716 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
717 FIXME("(%p)\n", This
);
720 static HRESULT WINAPI
ISF_ControlPanel_fnEnumSearches(IShellFolder2
*iface
,
721 IEnumExtraSearch
**ppenum
)
723 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
724 FIXME("(%p)\n", This
);
727 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2
*iface
, DWORD dwRes
,
728 ULONG
*pSort
, ULONG
*pDisplay
)
730 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
732 TRACE("(%p)\n", This
);
734 if (pSort
) *pSort
= 0;
735 if (pDisplay
) *pDisplay
= 0;
738 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2
*iface
, UINT iColumn
,
741 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
743 TRACE("(%p)\n", This
);
745 if (!pcsFlags
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
) return E_INVALIDARG
;
746 *pcsFlags
= ControlPanelSFHeader
[iColumn
].pcsFlags
;
749 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsEx(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
750 const SHCOLUMNID
*pscid
, VARIANT
*pv
)
752 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
753 FIXME("(%p)\n", This
);
757 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsOf(IShellFolder2
*iface
, LPCITEMIDLIST pidl
,
758 UINT iColumn
, SHELLDETAILS
*psd
)
760 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
761 PIDLCPanelStruct
* pcpanel
;
764 TRACE("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
766 if (!psd
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
)
770 psd
->fmt
= ControlPanelSFHeader
[iColumn
].fmt
;
771 psd
->cxChar
= ControlPanelSFHeader
[iColumn
].cxChar
;
772 psd
->str
.uType
= STRRET_CSTR
;
773 LoadStringA(shell32_hInstance
, ControlPanelSFHeader
[iColumn
].colnameid
, psd
->str
.u
.cStr
, MAX_PATH
);
776 psd
->str
.u
.cStr
[0] = 0x00;
777 psd
->str
.uType
= STRRET_CSTR
;
780 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
, SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
782 case 1: /* comment */
783 pcpanel
= _ILGetCPanelPointer(pidl
);
786 lstrcpyA(psd
->str
.u
.cStr
, pcpanel
->szName
+pcpanel
->offsComment
);
788 _ILGetFileType(pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
797 static HRESULT WINAPI
ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2
*iface
, UINT column
,
800 ICPanelImpl
*This
= impl_from_IShellFolder2(iface
);
801 FIXME("(%p)\n", This
);
805 static const IShellFolder2Vtbl vt_ShellFolder2
=
808 ISF_ControlPanel_fnQueryInterface
,
809 ISF_ControlPanel_fnAddRef
,
810 ISF_ControlPanel_fnRelease
,
811 ISF_ControlPanel_fnParseDisplayName
,
812 ISF_ControlPanel_fnEnumObjects
,
813 ISF_ControlPanel_fnBindToObject
,
814 ISF_ControlPanel_fnBindToStorage
,
815 ISF_ControlPanel_fnCompareIDs
,
816 ISF_ControlPanel_fnCreateViewObject
,
817 ISF_ControlPanel_fnGetAttributesOf
,
818 ISF_ControlPanel_fnGetUIObjectOf
,
819 ISF_ControlPanel_fnGetDisplayNameOf
,
820 ISF_ControlPanel_fnSetNameOf
,
823 ISF_ControlPanel_fnGetDefaultSearchGUID
,
824 ISF_ControlPanel_fnEnumSearches
,
825 ISF_ControlPanel_fnGetDefaultColumn
,
826 ISF_ControlPanel_fnGetDefaultColumnState
,
827 ISF_ControlPanel_fnGetDetailsEx
,
828 ISF_ControlPanel_fnGetDetailsOf
,
829 ISF_ControlPanel_fnMapColumnToSCID
832 /************************************************************************
833 * ICPanel_PersistFolder2_QueryInterface
835 static HRESULT WINAPI
ICPanel_PersistFolder2_QueryInterface(IPersistFolder2
* iface
, REFIID iid
, LPVOID
* ppvObject
)
837 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
839 TRACE("(%p)\n", This
);
841 return IShellFolder2_QueryInterface(&This
->IShellFolder2_iface
, iid
, ppvObject
);
844 /************************************************************************
845 * ICPanel_PersistFolder2_AddRef
847 static ULONG WINAPI
ICPanel_PersistFolder2_AddRef(IPersistFolder2
* iface
)
849 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
851 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
853 return IShellFolder2_AddRef(&This
->IShellFolder2_iface
);
856 /************************************************************************
857 * ISFPersistFolder_Release
859 static ULONG WINAPI
ICPanel_PersistFolder2_Release(IPersistFolder2
* iface
)
861 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
863 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
865 return IShellFolder2_Release(&This
->IShellFolder2_iface
);
868 /************************************************************************
869 * ICPanel_PersistFolder2_GetClassID
871 static HRESULT WINAPI
ICPanel_PersistFolder2_GetClassID(IPersistFolder2
* iface
, CLSID
* lpClassId
)
873 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
875 TRACE("(%p)\n", This
);
879 *lpClassId
= CLSID_ControlPanel
;
884 /************************************************************************
885 * ICPanel_PersistFolder2_Initialize
887 * NOTES: it makes no sense to change the pidl
889 static HRESULT WINAPI
ICPanel_PersistFolder2_Initialize(IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
891 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
892 TRACE("(%p)->(%p)\n", This
, pidl
);
896 /**************************************************************************
897 * IPersistFolder2_fnGetCurFolder
899 static HRESULT WINAPI
ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2
* iface
, LPITEMIDLIST
* pidl
)
901 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
903 TRACE("(%p)->(%p)\n", This
, pidl
);
907 *pidl
= ILClone(This
->pidlRoot
);
911 static const IPersistFolder2Vtbl vt_PersistFolder2
=
914 ICPanel_PersistFolder2_QueryInterface
,
915 ICPanel_PersistFolder2_AddRef
,
916 ICPanel_PersistFolder2_Release
,
917 ICPanel_PersistFolder2_GetClassID
,
918 ICPanel_PersistFolder2_Initialize
,
919 ICPanel_PersistFolder2_GetCurFolder
922 HRESULT
CPanel_GetIconLocationW(LPCITEMIDLIST pidl
,
923 LPWSTR szIconFile
, UINT cchMax
, int* piIndex
)
925 PIDLCPanelStruct
* pcpanel
= _ILGetCPanelPointer(pidl
);
930 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, szIconFile
, cchMax
);
931 *piIndex
= pcpanel
->iconIdx
!=-1? pcpanel
->iconIdx
: 0;
937 /**************************************************************************
938 * IShellExecuteHookW Implementation
941 static HRESULT WINAPI
IShellExecuteHookW_fnQueryInterface(
942 IShellExecuteHookW
* iface
, REFIID riid
, void** ppvObject
)
944 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
946 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
948 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
951 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnAddRef(IShellExecuteHookW
* iface
)
953 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
955 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
957 return IUnknown_AddRef(This
->pUnkOuter
);
960 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnRelease(IShellExecuteHookW
* iface
)
962 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
964 TRACE("(%p)\n", This
);
966 return IUnknown_Release(This
->pUnkOuter
);
969 static HRESULT WINAPI
IShellExecuteHookW_fnExecute(IShellExecuteHookW
*iface
,
970 LPSHELLEXECUTEINFOW psei
)
972 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
973 static const WCHAR wCplopen
[] = {'c','p','l','o','p','e','n','\0'};
975 SHELLEXECUTEINFOW sei_tmp
;
976 PIDLCPanelStruct
* pcpanel
;
977 WCHAR path
[MAX_PATH
];
978 WCHAR params
[MAX_PATH
];
982 TRACE("(%p)->execute(%p)\n", This
, psei
);
987 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
993 /* Return value from MultiByteToWideChar includes terminating NUL, which
994 * compensates for the starting double quote we just put in */
995 l
= MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, path
+1, MAX_PATH
-1);
997 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1001 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
+pcpanel
->offsDispName
, -1, params
, MAX_PATH
);
1004 sei_tmp
.lpFile
= path
;
1005 sei_tmp
.lpParameters
= params
;
1006 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1007 sei_tmp
.lpVerb
= wCplopen
;
1009 ret
= ShellExecuteExW(&sei_tmp
);
1016 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW
=
1019 IShellExecuteHookW_fnQueryInterface
,
1020 IShellExecuteHookW_fnAddRef
,
1021 IShellExecuteHookW_fnRelease
,
1023 IShellExecuteHookW_fnExecute
1027 /**************************************************************************
1028 * IShellExecuteHookA Implementation
1031 static HRESULT WINAPI
IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA
* iface
, REFIID riid
, void** ppvObject
)
1033 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1035 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
1037 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
1040 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnAddRef(IShellExecuteHookA
* iface
)
1042 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1044 TRACE("(%p)->(count=%u)\n", This
, This
->ref
);
1046 return IUnknown_AddRef(This
->pUnkOuter
);
1049 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnRelease(IShellExecuteHookA
* iface
)
1051 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1053 TRACE("(%p)\n", This
);
1055 return IUnknown_Release(This
->pUnkOuter
);
1058 static HRESULT WINAPI
IShellExecuteHookA_fnExecute(IShellExecuteHookA
*iface
,
1059 LPSHELLEXECUTEINFOA psei
)
1061 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1063 SHELLEXECUTEINFOA sei_tmp
;
1064 PIDLCPanelStruct
* pcpanel
;
1065 char path
[MAX_PATH
];
1068 TRACE("(%p)->execute(%p)\n", This
, psei
);
1071 return E_INVALIDARG
;
1073 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
1076 return E_INVALIDARG
;
1079 lstrcpyA(path
+1, pcpanel
->szName
);
1081 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1082 lstrcatA(path
, "\" ");
1083 lstrcatA(path
, pcpanel
->szName
+pcpanel
->offsDispName
);
1086 sei_tmp
.lpFile
= path
;
1087 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1089 ret
= ShellExecuteExA(&sei_tmp
);
1096 static const IShellExecuteHookAVtbl vt_ShellExecuteHookA
=
1098 IShellExecuteHookA_fnQueryInterface
,
1099 IShellExecuteHookA_fnAddRef
,
1100 IShellExecuteHookA_fnRelease
,
1101 IShellExecuteHookA_fnExecute