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
44 #include "enumidlist.h"
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 const IShellFolder2Vtbl
*lpVtbl
;
63 const IPersistFolder2Vtbl
*lpVtblPersistFolder2
;
64 const IShellExecuteHookWVtbl
*lpVtblShellExecuteHookW
;
65 const IShellExecuteHookAVtbl
*lpVtblShellExecuteHookA
;
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_IPersistFolder2( IPersistFolder2
*iface
)
81 return (ICPanelImpl
*)((char*)iface
- FIELD_OFFSET(ICPanelImpl
, lpVtblPersistFolder2
));
84 static inline ICPanelImpl
*impl_from_IShellExecuteHookW( IShellExecuteHookW
*iface
)
86 return (ICPanelImpl
*)((char*)iface
- FIELD_OFFSET(ICPanelImpl
, lpVtblShellExecuteHookW
));
89 static inline ICPanelImpl
*impl_from_IShellExecuteHookA( IShellExecuteHookA
*iface
)
91 return (ICPanelImpl
*)((char*)iface
- FIELD_OFFSET(ICPanelImpl
, lpVtblShellExecuteHookA
));
96 converts This to an interface pointer
98 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
99 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
100 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl)
102 #define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2)
103 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2)
104 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
105 #define _IShellExecuteHookW_(This) (IShellExecuteHookW*)&(This->lpVtblShellExecuteHookW)
106 #define _IShellExecuteHookA_(This) (IShellExecuteHookA*)&(This->lpVtblShellExecuteHookA)
108 /***********************************************************************
109 * IShellFolder [ControlPanel] implementation
112 static shvheader ControlPanelSFHeader
[] = {
113 {IDS_SHV_COLUMN8
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 15},/*FIXME*/
114 {IDS_SHV_COLUMN9
, SHCOLSTATE_TYPE_STR
| SHCOLSTATE_ONBYDEFAULT
, LVCFMT_RIGHT
, 200},/*FIXME*/
117 #define CONROLPANELSHELLVIEWCOLUMNS 2
119 /**************************************************************************
120 * IControlPanel_Constructor
122 HRESULT WINAPI
IControlPanel_Constructor(IUnknown
* pUnkOuter
, REFIID riid
, LPVOID
* ppv
)
126 TRACE("unkOut=%p %s\n", pUnkOuter
, shdebugstr_guid(riid
));
130 if (pUnkOuter
&& !IsEqualIID (riid
, &IID_IUnknown
))
131 return CLASS_E_NOAGGREGATION
;
133 sf
= (ICPanelImpl
*) LocalAlloc(LMEM_ZEROINIT
, sizeof(ICPanelImpl
));
135 return E_OUTOFMEMORY
;
138 sf
->lpVtbl
= &vt_ShellFolder2
;
139 sf
->lpVtblPersistFolder2
= &vt_PersistFolder2
;
140 sf
->lpVtblShellExecuteHookW
= &vt_ShellExecuteHookW
;
141 sf
->lpVtblShellExecuteHookA
= &vt_ShellExecuteHookA
;
142 sf
->pidlRoot
= _ILCreateControlPanel(); /* my qualified pidl */
143 sf
->pUnkOuter
= pUnkOuter
? pUnkOuter
: _IUnknown_ (sf
);
145 if (!SUCCEEDED(IUnknown_QueryInterface(_IUnknown_(sf
), riid
, ppv
))) {
146 IUnknown_Release(_IUnknown_(sf
));
147 return E_NOINTERFACE
;
150 TRACE("--(%p)\n", sf
);
154 /**************************************************************************
155 * ISF_ControlPanel_fnQueryInterface
157 * NOTES supports not IPersist/IPersistFolder
159 static HRESULT WINAPI
ISF_ControlPanel_fnQueryInterface(IShellFolder2
* iface
, REFIID riid
, LPVOID
* ppvObject
)
161 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
163 TRACE("(%p)->(%s,%p)\n", This
, shdebugstr_guid(riid
), ppvObject
);
167 if (IsEqualIID(riid
, &IID_IUnknown
) ||
168 IsEqualIID(riid
, &IID_IShellFolder
) || IsEqualIID(riid
, &IID_IShellFolder2
))
170 else if (IsEqualIID(riid
, &IID_IPersist
) ||
171 IsEqualIID(riid
, &IID_IPersistFolder
) || IsEqualIID(riid
, &IID_IPersistFolder2
))
172 *ppvObject
= _IPersistFolder2_(This
);
173 else if (IsEqualIID(riid
, &IID_IShellExecuteHookW
))
174 *ppvObject
= _IShellExecuteHookW_(This
);
175 else if (IsEqualIID(riid
, &IID_IShellExecuteHookA
))
176 *ppvObject
= _IShellExecuteHookA_(This
);
179 IUnknown_AddRef((IUnknown
*)(*ppvObject
));
180 TRACE("-- Interface:(%p)->(%p)\n", ppvObject
, *ppvObject
);
183 TRACE("-- Interface: E_NOINTERFACE\n");
184 return E_NOINTERFACE
;
187 static ULONG WINAPI
ISF_ControlPanel_fnAddRef(IShellFolder2
* iface
)
189 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
190 ULONG refCount
= InterlockedIncrement(&This
->ref
);
192 TRACE("(%p)->(count=%lu)\n", This
, refCount
- 1);
197 static ULONG WINAPI
ISF_ControlPanel_fnRelease(IShellFolder2
* iface
)
199 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
200 ULONG refCount
= InterlockedDecrement(&This
->ref
);
202 TRACE("(%p)->(count=%lu)\n", This
, refCount
+ 1);
205 TRACE("-- destroying IShellFolder(%p)\n", This
);
207 SHFree(This
->pidlRoot
);
208 LocalFree((HLOCAL
) This
);
213 /**************************************************************************
214 * ISF_ControlPanel_fnParseDisplayName
216 static HRESULT WINAPI
217 ISF_ControlPanel_fnParseDisplayName(IShellFolder2
* iface
,
220 LPOLESTR lpszDisplayName
,
221 DWORD
* pchEaten
, LPITEMIDLIST
* ppidl
, DWORD
* pdwAttributes
)
223 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
225 HRESULT hr
= E_INVALIDARG
;
227 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
228 This
, hwndOwner
, pbc
, lpszDisplayName
, debugstr_w(lpszDisplayName
), pchEaten
, ppidl
, pdwAttributes
);
234 TRACE("(%p)->(-- ret=0x%08lx)\n", This
, hr
);
239 static LPITEMIDLIST
_ILCreateCPanelApplet(LPCSTR name
, LPCSTR displayName
,
240 LPCSTR comment
, int iconIdx
)
245 int size0
= (char*)&tmp
.u
.cpanel
.szName
-(char*)&tmp
.u
.cpanel
;
249 tmp
.type
= PT_CPLAPPLET
;
250 tmp
.u
.cpanel
.dummy
= 0;
251 tmp
.u
.cpanel
.iconIdx
= iconIdx
;
256 tmp
.u
.cpanel
.offsDispName
= l
+1;
257 l
= strlen(displayName
);
260 tmp
.u
.cpanel
.offsComment
= tmp
.u
.cpanel
.offsDispName
+1+l
;
264 pidl
= SHAlloc(size
+4);
268 pidl
->mkid
.cb
= size
+2;
269 memcpy(pidl
->mkid
.abID
, &tmp
, 2+size0
);
271 p
= &((PIDLDATA
*)pidl
->mkid
.abID
)->u
.cpanel
;
272 strcpy(p
->szName
, name
);
273 strcpy(p
->szName
+tmp
.u
.cpanel
.offsDispName
, displayName
);
274 strcpy(p
->szName
+tmp
.u
.cpanel
.offsComment
, comment
);
276 *(WORD
*)((char*)pidl
+(size
+2)) = 0;
283 /**************************************************************************
284 * _ILGetCPanelPointer()
285 * gets a pointer to the control panel struct stored in the pidl
287 static PIDLCPanelStruct
* _ILGetCPanelPointer(LPCITEMIDLIST pidl
)
289 LPPIDLDATA pdata
= _ILGetDataPointer(pidl
);
291 if (pdata
&& pdata
->type
==PT_CPLAPPLET
)
292 return (PIDLCPanelStruct
*)&(pdata
->u
.cpanel
);
297 /**************************************************************************
298 * ISF_ControlPanel_fnEnumObjects
300 static BOOL
SHELL_RegisterCPanelApp(IEnumIDList
* list
, LPCSTR path
)
309 char displayName
[MAX_PATH
];
310 char comment
[MAX_PATH
];
312 WCHAR wpath
[MAX_PATH
];
314 MultiByteToWideChar(CP_ACP
, 0, path
, -1, wpath
, MAX_PATH
);
317 applet
= Control_LoadApplet(0, wpath
, &panel
);
321 for(i
=0; i
<applet
->count
; ++i
)
323 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].szName
, -1, displayName
, MAX_PATH
, 0, 0);
324 WideCharToMultiByte(CP_ACP
, 0, applet
->info
[i
].szInfo
, -1, comment
, MAX_PATH
, 0, 0);
326 applet
->proc(0, CPL_INQUIRE
, i
, (LPARAM
)&info
);
329 iconIdx
= -info
.idIcon
; /* negative icon index instead of icon number */
333 pidl
= _ILCreateCPanelApplet(path
, displayName
, comment
, iconIdx
);
336 AddToEnumList(list
, pidl
);
338 Control_UnloadApplet(applet
);
343 static int SHELL_RegisterRegistryCPanelApps(IEnumIDList
* list
, HKEY hkey_root
, LPCSTR szRepPath
)
346 char value
[MAX_PATH
];
351 if (RegOpenKeyA(hkey_root
, szRepPath
, &hkey
) == ERROR_SUCCESS
)
357 DWORD nameLen
= MAX_PATH
;
358 DWORD valueLen
= MAX_PATH
;
360 if (RegEnumValueA(hkey
, idx
, name
, &nameLen
, NULL
, NULL
, (LPBYTE
)&value
, &valueLen
) != ERROR_SUCCESS
)
363 if (SHELL_RegisterCPanelApp(list
, value
))
372 static int SHELL_RegisterCPanelFolders(IEnumIDList
* list
, HKEY hkey_root
, LPCSTR szRepPath
)
379 if (RegOpenKeyA(hkey_root
, szRepPath
, &hkey
) == ERROR_SUCCESS
)
384 if (RegEnumKeyA(hkey
, idx
, name
, MAX_PATH
) != ERROR_SUCCESS
)
389 LPITEMIDLIST pidl
= _ILCreateGuidFromStrA(name
);
391 if (pidl
&& AddToEnumList(list
, pidl
))
402 /**************************************************************************
403 * CreateCPanelEnumList()
405 static BOOL
CreateCPanelEnumList(
409 CHAR szPath
[MAX_PATH
];
410 WIN32_FIND_DATAA wfd
;
413 TRACE("(%p)->(flags=0x%08lx)\n", iface
, dwFlags
);
415 /* enumerate control panel folders folders */
416 if (dwFlags
& SHCONTF_FOLDERS
)
417 SHELL_RegisterCPanelFolders(iface
, HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
419 /* enumerate the control panel applets */
420 if (dwFlags
& SHCONTF_NONFOLDERS
)
424 GetSystemDirectoryA(szPath
, MAX_PATH
);
425 p
= PathAddBackslashA(szPath
);
428 TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface
,debugstr_a(szPath
));
429 hFile
= FindFirstFileA(szPath
, &wfd
);
431 if (hFile
!= INVALID_HANDLE_VALUE
)
435 if (!(dwFlags
& SHCONTF_INCLUDEHIDDEN
) && (wfd
.dwFileAttributes
& FILE_ATTRIBUTE_HIDDEN
))
438 if (!(wfd
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)) {
439 strcpy(p
, wfd
.cFileName
);
440 SHELL_RegisterCPanelApp((IEnumIDList
*)iface
, szPath
);
442 } while(FindNextFileA(hFile
, &wfd
));
446 SHELL_RegisterRegistryCPanelApps((IEnumIDList
*)iface
, HKEY_LOCAL_MACHINE
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
447 SHELL_RegisterRegistryCPanelApps((IEnumIDList
*)iface
, HKEY_CURRENT_USER
, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
452 /**************************************************************************
453 * ISF_ControlPanel_fnEnumObjects
455 static HRESULT WINAPI
456 ISF_ControlPanel_fnEnumObjects(IShellFolder2
* iface
, HWND hwndOwner
, DWORD dwFlags
, LPENUMIDLIST
* ppEnumIDList
)
458 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
460 TRACE("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This
, hwndOwner
, dwFlags
, ppEnumIDList
);
462 *ppEnumIDList
= IEnumIDList_Constructor();
464 CreateCPanelEnumList(*ppEnumIDList
, dwFlags
);
466 TRACE("--(%p)->(new ID List: %p)\n", This
, *ppEnumIDList
);
468 return(*ppEnumIDList
) ? S_OK
: E_OUTOFMEMORY
;
471 /**************************************************************************
472 * ISF_ControlPanel_fnBindToObject
474 static HRESULT WINAPI
475 ISF_ControlPanel_fnBindToObject(IShellFolder2
* iface
, LPCITEMIDLIST pidl
,
476 LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
478 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
480 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
482 return SHELL32_BindToChild(This
->pidlRoot
, NULL
, pidl
, riid
, ppvOut
);
485 /**************************************************************************
486 * ISF_ControlPanel_fnBindToStorage
488 static HRESULT WINAPI
489 ISF_ControlPanel_fnBindToStorage(IShellFolder2
* iface
,
490 LPCITEMIDLIST pidl
, LPBC pbcReserved
, REFIID riid
, LPVOID
* ppvOut
)
492 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
494 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This
, pidl
, pbcReserved
, shdebugstr_guid(riid
), ppvOut
);
500 /**************************************************************************
501 * ISF_ControlPanel_fnCompareIDs
504 static HRESULT WINAPI
505 ISF_ControlPanel_fnCompareIDs(IShellFolder2
* iface
, LPARAM lParam
, LPCITEMIDLIST pidl1
, LPCITEMIDLIST pidl2
)
507 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
511 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This
, lParam
, pidl1
, pidl2
);
512 nReturn
= SHELL32_CompareIDs(_IShellFolder_(This
), lParam
, pidl1
, pidl2
);
513 TRACE("-- %i\n", nReturn
);
517 /**************************************************************************
518 * ISF_ControlPanel_fnCreateViewObject
520 static HRESULT WINAPI
521 ISF_ControlPanel_fnCreateViewObject(IShellFolder2
* iface
, HWND hwndOwner
, REFIID riid
, LPVOID
* ppvOut
)
523 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
525 LPSHELLVIEW pShellView
;
526 HRESULT hr
= E_INVALIDARG
;
528 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This
, hwndOwner
, shdebugstr_guid(riid
), ppvOut
);
533 if (IsEqualIID(riid
, &IID_IDropTarget
)) {
534 WARN("IDropTarget not implemented\n");
536 } else if (IsEqualIID(riid
, &IID_IContextMenu
)) {
537 WARN("IContextMenu not implemented\n");
539 } else if (IsEqualIID(riid
, &IID_IShellView
)) {
540 pShellView
= IShellView_Constructor((IShellFolder
*) iface
);
542 hr
= IShellView_QueryInterface(pShellView
, riid
, ppvOut
);
543 IShellView_Release(pShellView
);
547 TRACE("--(%p)->(interface=%p)\n", This
, ppvOut
);
551 /**************************************************************************
552 * ISF_ControlPanel_fnGetAttributesOf
554 static HRESULT WINAPI
555 ISF_ControlPanel_fnGetAttributesOf(IShellFolder2
* iface
, UINT cidl
, LPCITEMIDLIST
* apidl
, DWORD
* rgfInOut
)
557 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
561 TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08lx))\n",
562 This
, cidl
, apidl
, rgfInOut
, rgfInOut
? *rgfInOut
: 0);
572 while(cidl
> 0 && *apidl
) {
574 SHELL32_GetItemAttributes(_IShellFolder_(This
), *apidl
, rgfInOut
);
578 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
579 *rgfInOut
&= ~SFGAO_VALIDATE
;
581 TRACE("-- result=0x%08lx\n", *rgfInOut
);
585 /**************************************************************************
586 * ISF_ControlPanel_fnGetUIObjectOf
589 * HWND hwndOwner, //[in ] Parent window for any output
590 * UINT cidl, //[in ] array size
591 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
592 * REFIID riid, //[in ] Requested Interface
593 * UINT* prgfInOut, //[ ] reserved
594 * LPVOID* ppvObject) //[out] Resulting Interface
597 static HRESULT WINAPI
598 ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2
* iface
,
600 UINT cidl
, LPCITEMIDLIST
* apidl
, REFIID riid
, UINT
* prgfInOut
, LPVOID
* ppvOut
)
602 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
605 IUnknown
*pObj
= NULL
;
606 HRESULT hr
= E_INVALIDARG
;
608 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
609 This
, hwndOwner
, cidl
, apidl
, shdebugstr_guid(riid
), prgfInOut
, ppvOut
);
614 if (IsEqualIID(riid
, &IID_IContextMenu
) &&(cidl
>= 1)) {
615 pObj
= (LPUNKNOWN
) ISvItemCm_Constructor((IShellFolder
*) iface
, This
->pidlRoot
, apidl
, cidl
);
617 } else if (IsEqualIID(riid
, &IID_IDataObject
) &&(cidl
>= 1)) {
618 pObj
= (LPUNKNOWN
) IDataObject_Constructor(hwndOwner
, This
->pidlRoot
, apidl
, cidl
);
620 } else if (IsEqualIID(riid
, &IID_IExtractIconA
) &&(cidl
== 1)) {
621 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
622 pObj
= (LPUNKNOWN
) IExtractIconA_Constructor(pidl
);
625 } else if (IsEqualIID(riid
, &IID_IExtractIconW
) &&(cidl
== 1)) {
626 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
627 pObj
= (LPUNKNOWN
) IExtractIconW_Constructor(pidl
);
630 } else if ((IsEqualIID(riid
,&IID_IShellLinkW
) || IsEqualIID(riid
,&IID_IShellLinkA
))
632 pidl
= ILCombine(This
->pidlRoot
, apidl
[0]);
633 hr
= IShellLink_ConstructFromFile(NULL
, riid
, pidl
,(LPVOID
*)&pObj
);
639 if (SUCCEEDED(hr
) && !pObj
)
644 TRACE("(%p)->hr=0x%08lx\n", This
, hr
);
648 /**************************************************************************
649 * ISF_ControlPanel_fnGetDisplayNameOf
651 static HRESULT WINAPI
ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2
* iface
, LPCITEMIDLIST pidl
, DWORD dwFlags
, LPSTRRET strRet
)
653 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
655 CHAR szPath
[MAX_PATH
];
656 WCHAR wszPath
[MAX_PATH
+1]; /* +1 for potential backslash */
657 PIDLCPanelStruct
* pcpanel
;
661 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n", This
, pidl
, dwFlags
, strRet
);
664 if (!pidl
|| !strRet
)
667 pcpanel
= _ILGetCPanelPointer(pidl
);
670 lstrcpyA(szPath
, pcpanel
->szName
+pcpanel
->offsDispName
);
672 if (!(dwFlags
& SHGDN_FORPARSING
))
673 FIXME("retrieve display name from control panel app\n");
675 /* take names of special folders only if its only this folder */
676 else if (_ILIsSpecialFolder(pidl
)) {
677 BOOL bSimplePidl
= _ILIsPidlSimple(pidl
);
680 _ILSimpleGetTextW(pidl
, wszPath
, MAX_PATH
); /* append my own path */
682 FIXME("special pidl\n");
685 if ((dwFlags
& SHGDN_FORPARSING
) && !bSimplePidl
) { /* go deeper if needed */
688 PathAddBackslashW(wszPath
);
689 len
= lstrlenW(wszPath
);
692 (SHELL32_GetDisplayNameOfChild(iface
, pidl
, dwFlags
| SHGDN_INFOLDER
, wszPath
+ len
, MAX_PATH
+ 1 - len
)))
693 return E_OUTOFMEMORY
;
694 if (!WideCharToMultiByte(CP_ACP
, 0, wszPath
, -1, szPath
, MAX_PATH
, NULL
, NULL
))
699 strRet
->uType
= STRRET_CSTR
;
700 lstrcpynA(strRet
->u
.cStr
, szPath
, MAX_PATH
);
702 TRACE("--(%p)->(%s)\n", This
, szPath
);
706 /**************************************************************************
707 * ISF_ControlPanel_fnSetNameOf
708 * Changes the name of a file object or subfolder, possibly changing its item
709 * identifier in the process.
712 * HWND hwndOwner, //[in ] Owner window for output
713 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
714 * LPCOLESTR lpszName, //[in ] the items new display name
715 * DWORD dwFlags, //[in ] SHGNO formatting flags
716 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
718 static HRESULT WINAPI
ISF_ControlPanel_fnSetNameOf(IShellFolder2
* iface
, HWND hwndOwner
, LPCITEMIDLIST pidl
, /*simple pidl */
719 LPCOLESTR lpName
, DWORD dwFlags
, LPITEMIDLIST
* pPidlOut
)
721 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
722 FIXME("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This
, hwndOwner
, pidl
, debugstr_w(lpName
), dwFlags
, pPidlOut
);
726 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2
* iface
, GUID
* pguid
)
728 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
729 FIXME("(%p)\n", This
);
732 static HRESULT WINAPI
ISF_ControlPanel_fnEnumSearches(IShellFolder2
* iface
, IEnumExtraSearch
** ppenum
)
734 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
735 FIXME("(%p)\n", This
);
738 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2
* iface
, DWORD dwRes
, ULONG
* pSort
, ULONG
* pDisplay
)
740 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
742 TRACE("(%p)\n", This
);
744 if (pSort
) *pSort
= 0;
745 if (pDisplay
) *pDisplay
= 0;
748 static HRESULT WINAPI
ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2
* iface
, UINT iColumn
, DWORD
* pcsFlags
)
750 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
752 TRACE("(%p)\n", This
);
754 if (!pcsFlags
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
) return E_INVALIDARG
;
755 *pcsFlags
= ControlPanelSFHeader
[iColumn
].pcsFlags
;
758 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsEx(IShellFolder2
* iface
, LPCITEMIDLIST pidl
, const SHCOLUMNID
* pscid
, VARIANT
* pv
)
760 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
761 FIXME("(%p)\n", This
);
765 static HRESULT WINAPI
ISF_ControlPanel_fnGetDetailsOf(IShellFolder2
* iface
, LPCITEMIDLIST pidl
, UINT iColumn
, SHELLDETAILS
* psd
)
767 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
770 TRACE("(%p)->(%p %i %p)\n", This
, pidl
, iColumn
, psd
);
772 if (!psd
|| iColumn
>= CONROLPANELSHELLVIEWCOLUMNS
)
776 psd
->fmt
= ControlPanelSFHeader
[iColumn
].fmt
;
777 psd
->cxChar
= ControlPanelSFHeader
[iColumn
].cxChar
;
778 psd
->str
.uType
= STRRET_CSTR
;
779 LoadStringA(shell32_hInstance
, ControlPanelSFHeader
[iColumn
].colnameid
, psd
->str
.u
.cStr
, MAX_PATH
);
782 psd
->str
.u
.cStr
[0] = 0x00;
783 psd
->str
.uType
= STRRET_CSTR
;
786 hr
= IShellFolder_GetDisplayNameOf(iface
, pidl
, SHGDN_NORMAL
| SHGDN_INFOLDER
, &psd
->str
);
788 case 1: /* comment */
789 _ILGetFileType(pidl
, psd
->str
.u
.cStr
, MAX_PATH
);
797 static HRESULT WINAPI
ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2
* iface
, UINT column
, SHCOLUMNID
* pscid
)
799 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
800 FIXME("(%p)\n", This
);
804 static const IShellFolder2Vtbl vt_ShellFolder2
=
807 ISF_ControlPanel_fnQueryInterface
,
808 ISF_ControlPanel_fnAddRef
,
809 ISF_ControlPanel_fnRelease
,
810 ISF_ControlPanel_fnParseDisplayName
,
811 ISF_ControlPanel_fnEnumObjects
,
812 ISF_ControlPanel_fnBindToObject
,
813 ISF_ControlPanel_fnBindToStorage
,
814 ISF_ControlPanel_fnCompareIDs
,
815 ISF_ControlPanel_fnCreateViewObject
,
816 ISF_ControlPanel_fnGetAttributesOf
,
817 ISF_ControlPanel_fnGetUIObjectOf
,
818 ISF_ControlPanel_fnGetDisplayNameOf
,
819 ISF_ControlPanel_fnSetNameOf
,
822 ISF_ControlPanel_fnGetDefaultSearchGUID
,
823 ISF_ControlPanel_fnEnumSearches
,
824 ISF_ControlPanel_fnGetDefaultColumn
,
825 ISF_ControlPanel_fnGetDefaultColumnState
,
826 ISF_ControlPanel_fnGetDetailsEx
,
827 ISF_ControlPanel_fnGetDetailsOf
,
828 ISF_ControlPanel_fnMapColumnToSCID
831 /************************************************************************
832 * ICPanel_PersistFolder2_QueryInterface
834 static HRESULT WINAPI
ICPanel_PersistFolder2_QueryInterface(IPersistFolder2
* iface
, REFIID iid
, LPVOID
* ppvObject
)
836 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
838 TRACE("(%p)\n", This
);
840 return IUnknown_QueryInterface(_IUnknown_(This
), iid
, ppvObject
);
843 /************************************************************************
844 * ICPanel_PersistFolder2_AddRef
846 static ULONG WINAPI
ICPanel_PersistFolder2_AddRef(IPersistFolder2
* iface
)
848 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
850 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
852 return IUnknown_AddRef(_IUnknown_(This
));
855 /************************************************************************
856 * ISFPersistFolder_Release
858 static ULONG WINAPI
ICPanel_PersistFolder2_Release(IPersistFolder2
* iface
)
860 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
862 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
864 return IUnknown_Release(_IUnknown_(This
));
867 /************************************************************************
868 * ICPanel_PersistFolder2_GetClassID
870 static HRESULT WINAPI
ICPanel_PersistFolder2_GetClassID(IPersistFolder2
* iface
, CLSID
* lpClassId
)
872 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
874 TRACE("(%p)\n", This
);
878 *lpClassId
= CLSID_ControlPanel
;
883 /************************************************************************
884 * ICPanel_PersistFolder2_Initialize
886 * NOTES: it makes no sense to change the pidl
888 static HRESULT WINAPI
ICPanel_PersistFolder2_Initialize(IPersistFolder2
* iface
, LPCITEMIDLIST pidl
)
890 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
891 TRACE("(%p)->(%p)\n", This
, pidl
);
895 /**************************************************************************
896 * IPersistFolder2_fnGetCurFolder
898 static HRESULT WINAPI
ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2
* iface
, LPITEMIDLIST
* pidl
)
900 ICPanelImpl
*This
= impl_from_IPersistFolder2(iface
);
902 TRACE("(%p)->(%p)\n", This
, pidl
);
906 *pidl
= ILClone(This
->pidlRoot
);
910 static const IPersistFolder2Vtbl vt_PersistFolder2
=
913 ICPanel_PersistFolder2_QueryInterface
,
914 ICPanel_PersistFolder2_AddRef
,
915 ICPanel_PersistFolder2_Release
,
916 ICPanel_PersistFolder2_GetClassID
,
917 ICPanel_PersistFolder2_Initialize
,
918 ICPanel_PersistFolder2_GetCurFolder
921 HRESULT
CPanel_GetIconLocationW(LPITEMIDLIST pidl
,
922 LPWSTR szIconFile
, UINT cchMax
, int* piIndex
)
924 PIDLCPanelStruct
* pcpanel
= _ILGetCPanelPointer(pidl
);
929 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, szIconFile
, cchMax
);
930 *piIndex
= pcpanel
->iconIdx
!=-1? pcpanel
->iconIdx
: 0;
936 /**************************************************************************
937 * IShellExecuteHookW Implementation
940 static HRESULT WINAPI
IShellExecuteHookW_fnQueryInterface(
941 IShellExecuteHookW
* iface
, REFIID riid
, void** ppvObject
)
943 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
945 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
947 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
950 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnAddRef(IShellExecuteHookW
* iface
)
952 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
954 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
956 return IUnknown_AddRef(This
->pUnkOuter
);
959 static ULONG STDMETHODCALLTYPE
IShellExecuteHookW_fnRelease(IShellExecuteHookW
* iface
)
961 ICPanelImpl
*This
= impl_from_IShellExecuteHookW(iface
);
963 TRACE("(%p)\n", This
);
965 return IUnknown_Release(This
->pUnkOuter
);
968 static HRESULT WINAPI
IShellExecuteHookW_fnExecute(IShellExecuteHookW
* iface
, LPSHELLEXECUTEINFOW psei
)
970 static const WCHAR wCplopen
[] = {'c','p','l','o','p','e','n','\0'};
971 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
973 SHELLEXECUTEINFOW sei_tmp
;
974 PIDLCPanelStruct
* pcpanel
;
975 WCHAR path
[MAX_PATH
];
976 WCHAR params
[MAX_PATH
];
980 TRACE("(%p)->execute(%p)\n", This
, psei
);
985 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
991 /* Return value from MultiByteToWideChar includes terminating NUL, which
992 * compensates for the starting double quote we just put in */
993 l
= MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
, -1, path
+1, MAX_PATH
);
995 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
999 MultiByteToWideChar(CP_ACP
, 0, pcpanel
->szName
+pcpanel
->offsDispName
, -1, params
, MAX_PATH
);
1001 memcpy(&sei_tmp
, psei
, sizeof(sei_tmp
));
1002 sei_tmp
.lpFile
= path
;
1003 sei_tmp
.lpParameters
= params
;
1004 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1005 sei_tmp
.lpVerb
= wCplopen
;
1007 ret
= ShellExecuteExW(&sei_tmp
);
1014 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW
=
1017 IShellExecuteHookW_fnQueryInterface
,
1018 IShellExecuteHookW_fnAddRef
,
1019 IShellExecuteHookW_fnRelease
,
1021 IShellExecuteHookW_fnExecute
1025 /**************************************************************************
1026 * IShellExecuteHookA Implementation
1029 static HRESULT WINAPI
IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA
* iface
, REFIID riid
, void** ppvObject
)
1031 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1033 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
1035 return IUnknown_QueryInterface(This
->pUnkOuter
, riid
, ppvObject
);
1038 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnAddRef(IShellExecuteHookA
* iface
)
1040 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1042 TRACE("(%p)->(count=%lu)\n", This
, This
->ref
);
1044 return IUnknown_AddRef(This
->pUnkOuter
);
1047 static ULONG STDMETHODCALLTYPE
IShellExecuteHookA_fnRelease(IShellExecuteHookA
* iface
)
1049 ICPanelImpl
*This
= impl_from_IShellExecuteHookA(iface
);
1051 TRACE("(%p)\n", This
);
1053 return IUnknown_Release(This
->pUnkOuter
);
1056 static HRESULT WINAPI
IShellExecuteHookA_fnExecute(IShellExecuteHookA
* iface
, LPSHELLEXECUTEINFOA psei
)
1058 ICPanelImpl
*This
= (ICPanelImpl
*)iface
;
1060 SHELLEXECUTEINFOA sei_tmp
;
1061 PIDLCPanelStruct
* pcpanel
;
1062 char path
[MAX_PATH
];
1065 TRACE("(%p)->execute(%p)\n", This
, psei
);
1068 return E_INVALIDARG
;
1070 pcpanel
= _ILGetCPanelPointer(ILFindLastID(psei
->lpIDList
));
1073 return E_INVALIDARG
;
1076 lstrcpyA(path
+1, pcpanel
->szName
);
1078 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1079 lstrcatA(path
, "\" ");
1080 lstrcatA(path
, pcpanel
->szName
+pcpanel
->offsDispName
);
1082 memcpy(&sei_tmp
, psei
, sizeof(sei_tmp
));
1083 sei_tmp
.lpFile
= path
;
1084 sei_tmp
.fMask
&= ~SEE_MASK_INVOKEIDLIST
;
1086 ret
= ShellExecuteExA(&sei_tmp
);
1093 static const IShellExecuteHookAVtbl vt_ShellExecuteHookA
=
1095 IShellExecuteHookA_fnQueryInterface
,
1096 IShellExecuteHookA_fnAddRef
,
1097 IShellExecuteHookA_fnRelease
,
1098 IShellExecuteHookA_fnExecute