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"
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
42 #include "enumidlist.h"
44 #include "undocshell.h"
45 #include "shell32_main.h"
48 #include "shellfolder.h"
49 #include "wine/debug.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(shell);
55 /***********************************************************************
56 * control panel implementation in shell namespace
60 ICOM_VFIELD(IShellFolder2);
63 ICOM_VTABLE(IPersistFolder2)* lpVtblPersistFolder2;
64 ICOM_VTABLE(IShellExecuteHookW)* lpVtblShellExecuteHookW;
65 ICOM_VTABLE(IShellExecuteHookA)* 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 ICOM_VTABLE(IShellFolder2) vt_ShellFolder2;
75 static ICOM_VTABLE(IPersistFolder2) vt_PersistFolder2;
76 static ICOM_VTABLE(IShellExecuteHookW) vt_ShellExecuteHookW;
77 static ICOM_VTABLE(IShellExecuteHookA) vt_ShellExecuteHookA;
79 #define _IPersistFolder2_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblPersistFolder2)))
80 #define _ICOM_THIS_From_IPersistFolder2(class, name) class* This = (class*)(((char*)name)-_IPersistFolder2_Offset);
82 #define IShellExecuteHookW_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookW)))
83 #define _ICOM_THIS_From_IShellExecuteHookW(class, name) class* This = (class*)(((char*)name)-IShellExecuteHookW_Offset);
85 #define IShellExecuteHookA_Offset ((int)(&(((ICPanelImpl*)0)->lpVtblShellExecuteHookA)))
86 #define _ICOM_THIS_From_IShellExecuteHookA(class, name) class* This = (class*)(((char*)name)-IShellExecuteHookA_Offset);
90 converts This to a interface pointer
92 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
93 #define _IShellFolder_(This) (IShellFolder*)&(This->lpVtbl)
94 #define _IShellFolder2_(This) (IShellFolder2*)&(This->lpVtbl)
96 #define _IPersist_(This) (IPersist*)&(This->lpVtblPersistFolder2)
97 #define _IPersistFolder_(This) (IPersistFolder*)&(This->lpVtblPersistFolder2)
98 #define _IPersistFolder2_(This) (IPersistFolder2*)&(This->lpVtblPersistFolder2)
99 #define _IShellExecuteHookW_(This) (IShellExecuteHookW*)&(This->lpVtblShellExecuteHookW)
100 #define _IShellExecuteHookA_(This) (IShellExecuteHookA*)&(This->lpVtblShellExecuteHookA)
102 /***********************************************************************
103 * IShellFolder [ControlPanel] implementation
106 static shvheader ControlPanelSFHeader[] = {
107 {IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},/*FIXME*/
108 {IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 200},/*FIXME*/
111 #define CONROLPANELSHELLVIEWCOLUMNS 2
113 /**************************************************************************
114 * IControlPanel_Constructor
116 HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID * ppv)
120 TRACE("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid(riid));
124 if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
125 return CLASS_E_NOAGGREGATION;
127 sf = (ICPanelImpl *) LocalAlloc(GMEM_ZEROINIT, sizeof(ICPanelImpl));
129 return E_OUTOFMEMORY;
132 sf->lpVtbl = &vt_ShellFolder2;
133 sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
134 sf->lpVtblShellExecuteHookW = &vt_ShellExecuteHookW;
135 sf->lpVtblShellExecuteHookA = &vt_ShellExecuteHookA;
136 sf->pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */
137 sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_ (sf);
139 if (!SUCCEEDED(IUnknown_QueryInterface(_IUnknown_(sf), riid, ppv))) {
140 IUnknown_Release(_IUnknown_(sf));
141 return E_NOINTERFACE;
144 TRACE("--(%p)\n", sf);
148 /**************************************************************************
149 * ISF_ControlPanel_fnQueryInterface
151 * NOTES supports not IPersist/IPersistFolder
153 static HRESULT WINAPI ISF_ControlPanel_fnQueryInterface(IShellFolder2 * iface, REFIID riid, LPVOID * ppvObject)
155 ICOM_THIS(ICPanelImpl, iface);
157 TRACE("(%p)->(%s,%p)\n", This, shdebugstr_guid(riid), ppvObject);
161 if (IsEqualIID(riid, &IID_IUnknown) ||
162 IsEqualIID(riid, &IID_IShellFolder) || IsEqualIID(riid, &IID_IShellFolder2))
164 else if (IsEqualIID(riid, &IID_IPersist) ||
165 IsEqualIID(riid, &IID_IPersistFolder) || IsEqualIID(riid, &IID_IPersistFolder2))
166 *ppvObject = _IPersistFolder2_(This);
167 else if (IsEqualIID(riid, &IID_IShellExecuteHookW))
168 *ppvObject = _IShellExecuteHookW_(This);
169 else if (IsEqualIID(riid, &IID_IShellExecuteHookA))
170 *ppvObject = _IShellExecuteHookA_(This);
173 IUnknown_AddRef((IUnknown *)(*ppvObject));
174 TRACE("-- Interface:(%p)->(%p)\n", ppvObject, *ppvObject);
177 TRACE("-- Interface: E_NOINTERFACE\n");
178 return E_NOINTERFACE;
181 static ULONG WINAPI ISF_ControlPanel_fnAddRef(IShellFolder2 * iface)
183 ICOM_THIS(ICPanelImpl, iface);
185 TRACE("(%p)->(count=%lu)\n", This, This->ref);
187 return ++(This->ref);
190 static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 * iface)
192 ICOM_THIS(ICPanelImpl, iface);
194 TRACE("(%p)->(count=%lu)\n", This, This->ref);
196 if (!--(This->ref)) {
197 TRACE("-- destroying IShellFolder(%p)\n", This);
199 SHFree(This->pidlRoot);
200 LocalFree((HLOCAL) This);
206 /**************************************************************************
207 * ISF_ControlPanel_fnParseDisplayName
209 static HRESULT WINAPI
210 ISF_ControlPanel_fnParseDisplayName(IShellFolder2 * iface,
213 LPOLESTR lpszDisplayName,
214 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
216 ICOM_THIS(ICPanelImpl, iface);
218 HRESULT hr = E_INVALIDARG;
220 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
221 This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes);
227 TRACE("(%p)->(-- ret=0x%08lx)\n", This, hr);
232 static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName,
233 LPCSTR comment, int iconIdx)
238 int size0 = (char*)&tmp.u.cpanel.szName-(char*)&tmp.u.cpanel;
243 tmp.u.cpanel.dummy = 0;
244 tmp.u.cpanel.iconIdx = iconIdx;
249 tmp.u.cpanel.offsDispName = l+1;
250 l = strlen(displayName);
253 tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName+1+l;
257 pidl = SHAlloc(size+4);
261 pidl->mkid.cb = size+2;
262 memcpy(pidl->mkid.abID, &tmp, 2+size0);
264 p = &((PIDLDATA*)pidl->mkid.abID)->u.cpanel;
265 strcpy(p->szName, name);
266 strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
267 strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
269 *(WORD*)((char*)pidl+(size+2)) = 0;
276 /**************************************************************************
277 * _ILGetCPanelPointer()
278 * gets a pointer to the control panel struct stored in the pidl
280 static PIDLCPanelStruct* _ILGetCPanelPointer(LPCITEMIDLIST pidl)
282 LPPIDLDATA pdata = _ILGetDataPointer(pidl);
284 if (pdata && pdata->type==0)
285 return (PIDLCPanelStruct*)&(pdata->u.cpanel);
290 /**************************************************************************
291 * ISF_ControlPanel_fnEnumObjects
293 static BOOL SHELL_RegisterCPanelApp(IEnumIDList* list, LPCSTR path)
302 char displayName[MAX_PATH];
303 char comment[MAX_PATH];
305 WCHAR wpath[MAX_PATH];
307 MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
310 applet = Control_LoadApplet(0, wpath, &panel);
314 for(i=0; i<applet->count; ++i)
316 WideCharToMultiByte(CP_ACP, 0, applet->info[i].szName, -1, displayName, MAX_PATH, 0, 0);
317 WideCharToMultiByte(CP_ACP, 0, applet->info[i].szInfo, -1, comment, MAX_PATH, 0, 0);
319 applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info);
322 iconIdx = -info.idIcon; /* negative icon index instead of icon number */
326 pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx);
329 AddToEnumList(list, pidl);
331 Control_UnloadApplet(applet);
336 static int SHELL_RegisterRegistryCPanelApps(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
339 char value[MAX_PATH];
344 if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
350 DWORD nameLen = MAX_PATH;
351 DWORD valueLen = MAX_PATH;
353 if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value, &valueLen) != ERROR_SUCCESS)
356 if (SHELL_RegisterCPanelApp(list, value))
365 static int SHELL_RegisterCPanelFolders(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
372 if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
377 if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
382 LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name);
384 if (pidl && AddToEnumList(list, pidl))
395 /**************************************************************************
396 * CreateCPanelEnumList()
398 static BOOL CreateCPanelEnumList(
402 CHAR szPath[MAX_PATH];
403 WIN32_FIND_DATAA wfd;
406 TRACE("(%p)->(flags=0x%08lx) \n",iface,dwFlags);
408 /* enumerate control panel folders folders */
409 if (dwFlags & SHCONTF_FOLDERS)
410 SHELL_RegisterCPanelFolders(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
412 /* enumerate the control panel applets */
413 if (dwFlags & SHCONTF_NONFOLDERS)
417 GetSystemDirectoryA(szPath, MAX_PATH);
418 p = PathAddBackslashA(szPath);
421 TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface,debugstr_a(szPath));
422 hFile = FindFirstFileA(szPath, &wfd);
424 if (hFile != INVALID_HANDLE_VALUE)
428 if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
431 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
432 strcpy(p, wfd.cFileName);
433 SHELL_RegisterCPanelApp((IEnumIDList*)iface, szPath);
435 } while(FindNextFileA(hFile, &wfd));
439 SHELL_RegisterRegistryCPanelApps((IEnumIDList*)iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
440 SHELL_RegisterRegistryCPanelApps((IEnumIDList*)iface, HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
445 /**************************************************************************
446 * ISF_ControlPanel_fnEnumObjects
448 static HRESULT WINAPI
449 ISF_ControlPanel_fnEnumObjects(IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
451 ICOM_THIS(ICPanelImpl, iface);
453 TRACE("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
455 *ppEnumIDList = IEnumIDList_Constructor();
457 CreateCPanelEnumList(*ppEnumIDList, dwFlags);
459 TRACE("--(%p)->(new ID List: %p)\n", This, *ppEnumIDList);
461 return(*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
464 /**************************************************************************
465 * ISF_ControlPanel_fnBindToObject
467 static HRESULT WINAPI
468 ISF_ControlPanel_fnBindToObject(IShellFolder2 * iface, LPCITEMIDLIST pidl,
469 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
471 ICOM_THIS(ICPanelImpl, iface);
473 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
475 return SHELL32_BindToChild(This->pidlRoot, NULL, pidl, riid, ppvOut);
478 /**************************************************************************
479 * ISF_ControlPanel_fnBindToStorage
481 static HRESULT WINAPI
482 ISF_ControlPanel_fnBindToStorage(IShellFolder2 * iface,
483 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
485 ICOM_THIS(ICPanelImpl, iface);
487 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
493 /**************************************************************************
494 * ISF_ControlPanel_fnCompareIDs
497 static HRESULT WINAPI
498 ISF_ControlPanel_fnCompareIDs(IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
500 ICOM_THIS(ICPanelImpl, iface);
504 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
505 nReturn = SHELL32_CompareIDs(_IShellFolder_(This), lParam, pidl1, pidl2);
506 TRACE("-- %i\n", nReturn);
510 /**************************************************************************
511 * ISF_ControlPanel_fnCreateViewObject
513 static HRESULT WINAPI
514 ISF_ControlPanel_fnCreateViewObject(IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
516 ICOM_THIS(ICPanelImpl, iface);
518 LPSHELLVIEW pShellView;
519 HRESULT hr = E_INVALIDARG;
521 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid(riid), ppvOut);
526 if (IsEqualIID(riid, &IID_IDropTarget)) {
527 WARN("IDropTarget not implemented\n");
529 } else if (IsEqualIID(riid, &IID_IContextMenu)) {
530 WARN("IContextMenu not implemented\n");
532 } else if (IsEqualIID(riid, &IID_IShellView)) {
533 pShellView = IShellView_Constructor((IShellFolder *) iface);
535 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
536 IShellView_Release(pShellView);
540 TRACE("--(%p)->(interface=%p)\n", This, ppvOut);
544 /**************************************************************************
545 * ISF_ControlPanel_fnGetAttributesOf
547 static HRESULT WINAPI
548 ISF_ControlPanel_fnGetAttributesOf(IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
550 ICOM_THIS(ICPanelImpl, iface);
554 TRACE("(%p)->(cidl=%d apidl=%p mask=0x%08lx)\n", This, cidl, apidl, *rgfInOut);
556 if ((!cidl) ||(!apidl) ||(!rgfInOut))
559 while(cidl > 0 && *apidl) {
561 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
566 TRACE("-- result=0x%08lx\n", *rgfInOut);
570 /**************************************************************************
571 * ISF_ControlPanel_fnGetUIObjectOf
574 * HWND hwndOwner, //[in ] Parent window for any output
575 * UINT cidl, //[in ] array size
576 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
577 * REFIID riid, //[in ] Requested Interface
578 * UINT* prgfInOut, //[ ] reserved
579 * LPVOID* ppvObject) //[out] Resulting Interface
582 static HRESULT WINAPI
583 ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 * iface,
585 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
587 ICOM_THIS(ICPanelImpl, iface);
590 IUnknown *pObj = NULL;
591 HRESULT hr = E_INVALIDARG;
593 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
594 This, hwndOwner, cidl, apidl, shdebugstr_guid(riid), prgfInOut, ppvOut);
599 if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
600 pObj = (LPUNKNOWN) ISvItemCm_Constructor((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
602 } else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
603 pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
605 } else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
606 pidl = ILCombine(This->pidlRoot, apidl[0]);
607 pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
610 } else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
611 pidl = ILCombine(This->pidlRoot, apidl[0]);
612 pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
615 } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
617 pidl = ILCombine(This->pidlRoot, apidl[0]);
618 hr = IShellLink_ConstructFromFile(NULL, riid, pidl,(LPVOID*)&pObj);
624 if (SUCCEEDED(hr) && !pObj)
629 TRACE("(%p)->hr=0x%08lx\n", This, hr);
633 /**************************************************************************
634 * ISF_ControlPanel_fnGetDisplayNameOf
636 static HRESULT WINAPI ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
638 ICOM_THIS(ICPanelImpl, iface);
640 CHAR szPath[MAX_PATH*2];
641 PIDLCPanelStruct* pcpanel;
645 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
648 if (!pidl || !strRet)
651 pcpanel = _ILGetCPanelPointer(pidl);
654 lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName);
656 if (!(dwFlags & SHGDN_FORPARSING))
657 FIXME("retrieve display name from control panel app\n");
659 /* take names of special folders only if its only this folder */
660 else if (_ILIsSpecialFolder(pidl)) {
661 BOOL bSimplePidl = _ILIsPidlSimple(pidl);
664 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
666 FIXME("special pidl\n");
669 if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */
672 PathAddBackslashA(szPath); /*FIXME*/
673 len = lstrlenA(szPath);
676 (SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len)))
677 return E_OUTOFMEMORY;
681 strRet->uType = STRRET_CSTR;
682 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
684 TRACE("--(%p)->(%s)\n", This, szPath);
688 /**************************************************************************
689 * ISF_ControlPanel_fnSetNameOf
690 * Changes the name of a file object or subfolder, possibly changing its item
691 * identifier in the process.
694 * HWND hwndOwner, //[in ] Owner window for output
695 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
696 * LPCOLESTR lpszName, //[in ] the items new display name
697 * DWORD dwFlags, //[in ] SHGNO formatting flags
698 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
700 static HRESULT WINAPI ISF_ControlPanel_fnSetNameOf(IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
701 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
703 ICOM_THIS(ICPanelImpl, iface);
704 FIXME("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w(lpName), dwFlags, pPidlOut);
708 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2 * iface, GUID * pguid)
710 ICOM_THIS(ICPanelImpl, iface);
711 FIXME("(%p)\n", This);
714 static HRESULT WINAPI ISF_ControlPanel_fnEnumSearches(IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
716 ICOM_THIS(ICPanelImpl, iface);
717 FIXME("(%p)\n", This);
720 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
722 ICOM_THIS(ICPanelImpl, iface);
724 TRACE("(%p)\n", This);
726 if (pSort) *pSort = 0;
727 if (pDisplay) *pDisplay = 0;
730 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
732 ICOM_THIS(ICPanelImpl, iface);
734 TRACE("(%p)\n", This);
736 if (!pcsFlags || iColumn >= CONROLPANELSHELLVIEWCOLUMNS) return E_INVALIDARG;
737 *pcsFlags = ControlPanelSFHeader[iColumn].pcsFlags;
740 static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsEx(IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
742 ICOM_THIS(ICPanelImpl, iface);
743 FIXME("(%p)\n", This);
747 static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
749 ICOM_THIS(ICPanelImpl, iface);
752 TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
754 if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS)
758 psd->fmt = ControlPanelSFHeader[iColumn].fmt;
759 psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
760 psd->str.uType = STRRET_CSTR;
761 LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
764 psd->str.u.cStr[0] = 0x00;
765 psd->str.uType = STRRET_CSTR;
768 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
770 case 1: /* comment */
771 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
779 static HRESULT WINAPI ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
781 ICOM_THIS(ICPanelImpl, iface);
782 FIXME("(%p)\n", This);
786 static ICOM_VTABLE(IShellFolder2) vt_ShellFolder2 =
788 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
790 ISF_ControlPanel_fnQueryInterface,
791 ISF_ControlPanel_fnAddRef,
792 ISF_ControlPanel_fnRelease,
793 ISF_ControlPanel_fnParseDisplayName,
794 ISF_ControlPanel_fnEnumObjects,
795 ISF_ControlPanel_fnBindToObject,
796 ISF_ControlPanel_fnBindToStorage,
797 ISF_ControlPanel_fnCompareIDs,
798 ISF_ControlPanel_fnCreateViewObject,
799 ISF_ControlPanel_fnGetAttributesOf,
800 ISF_ControlPanel_fnGetUIObjectOf,
801 ISF_ControlPanel_fnGetDisplayNameOf,
802 ISF_ControlPanel_fnSetNameOf,
805 ISF_ControlPanel_fnGetDefaultSearchGUID,
806 ISF_ControlPanel_fnEnumSearches,
807 ISF_ControlPanel_fnGetDefaultColumn,
808 ISF_ControlPanel_fnGetDefaultColumnState,
809 ISF_ControlPanel_fnGetDetailsEx,
810 ISF_ControlPanel_fnGetDetailsOf,
811 ISF_ControlPanel_fnMapColumnToSCID
814 /************************************************************************
815 * ICPanel_PersistFolder2_QueryInterface
817 static HRESULT WINAPI ICPanel_PersistFolder2_QueryInterface(IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObject)
819 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
821 TRACE("(%p)\n", This);
823 return IUnknown_QueryInterface(_IUnknown_(This), iid, ppvObject);
826 /************************************************************************
827 * ICPanel_PersistFolder2_AddRef
829 static ULONG WINAPI ICPanel_PersistFolder2_AddRef(IPersistFolder2 * iface)
831 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
833 TRACE("(%p)->(count=%lu)\n", This, This->ref);
835 return IUnknown_AddRef(_IUnknown_(This));
838 /************************************************************************
839 * ISFPersistFolder_Release
841 static ULONG WINAPI ICPanel_PersistFolder2_Release(IPersistFolder2 * iface)
843 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
845 TRACE("(%p)->(count=%lu)\n", This, This->ref);
847 return IUnknown_Release(_IUnknown_(This));
850 /************************************************************************
851 * ICPanel_PersistFolder2_GetClassID
853 static HRESULT WINAPI ICPanel_PersistFolder2_GetClassID(IPersistFolder2 * iface, CLSID * lpClassId)
855 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
857 TRACE("(%p)\n", This);
861 *lpClassId = CLSID_ControlPanel;
866 /************************************************************************
867 * ICPanel_PersistFolder2_Initialize
869 * NOTES: it makes no sense to change the pidl
871 static HRESULT WINAPI ICPanel_PersistFolder2_Initialize(IPersistFolder2 * iface, LPCITEMIDLIST pidl)
873 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
874 TRACE("(%p)->(%p)\n", This, pidl);
878 /**************************************************************************
879 * IPersistFolder2_fnGetCurFolder
881 static HRESULT WINAPI ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2 * iface, LPITEMIDLIST * pidl)
883 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
885 TRACE("(%p)->(%p)\n", This, pidl);
889 *pidl = ILClone(This->pidlRoot);
893 static ICOM_VTABLE(IPersistFolder2) vt_PersistFolder2 =
895 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
897 ICPanel_PersistFolder2_QueryInterface,
898 ICPanel_PersistFolder2_AddRef,
899 ICPanel_PersistFolder2_Release,
900 ICPanel_PersistFolder2_GetClassID,
901 ICPanel_PersistFolder2_Initialize,
902 ICPanel_PersistFolder2_GetCurFolder
905 HRESULT WINAPI CPanel_GetIconLocationA(LPITEMIDLIST pidl, LPSTR szIconFile, UINT cchMax, int* piIndex)
907 PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
912 lstrcpyA(szIconFile, pcpanel->szName);
913 *piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0;
918 HRESULT WINAPI CPanel_GetIconLocationW(LPITEMIDLIST pidl, LPWSTR szIconFile, UINT cchMax, int* piIndex)
920 PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
925 MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, szIconFile, cchMax);
926 *piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0;
932 /**************************************************************************
933 * IShellExecuteHookW Implementation
936 static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface(IShellExecuteHookW* iface, REFIID riid, void** ppvObject)
938 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl, iface);
940 TRACE("(%p)->(count=%lu)\n", This, This->ref);
942 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
945 static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnAddRef(IShellExecuteHookW* iface)
947 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl, iface);
949 TRACE("(%p)->(count=%lu)\n", This, This->ref);
951 return IUnknown_AddRef(This->pUnkOuter);
954 static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnRelease(IShellExecuteHookW* iface)
956 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl, iface);
958 TRACE("(%p)\n", This);
960 return IUnknown_Release(This->pUnkOuter);
963 static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW* iface, LPSHELLEXECUTEINFOW psei)
965 ICOM_THIS(ICPanelImpl, iface);
967 SHELLEXECUTEINFOW sei_tmp;
968 PIDLCPanelStruct* pcpanel;
969 WCHAR path[MAX_PATH];
973 TRACE("(%p)->execute(%p)\n", This, psei);
978 pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
984 l = 1 + MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, path+1, MAX_PATH);
986 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
990 MultiByteToWideChar(CP_ACP, 0, pcpanel->szName+pcpanel->offsDispName, -1, path+l, MAX_PATH);
992 memcpy(&sei_tmp, psei, sizeof(sei_tmp));
993 sei_tmp.lpFile = path;
994 sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
996 ret = ShellExecuteExW(&sei_tmp);
1003 static ICOM_VTABLE(IShellExecuteHookW) vt_ShellExecuteHookW =
1005 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1007 IShellExecuteHookW_fnQueryInterface,
1008 IShellExecuteHookW_fnAddRef,
1009 IShellExecuteHookW_fnRelease,
1011 IShellExecuteHookW_fnExecute
1015 /**************************************************************************
1016 * IShellExecuteHookA Implementation
1019 static HRESULT WINAPI IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA* iface, REFIID riid, void** ppvObject)
1021 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl, iface);
1023 TRACE("(%p)->(count=%lu)\n", This, This->ref);
1025 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
1028 static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnAddRef(IShellExecuteHookA* iface)
1030 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl, iface);
1032 TRACE("(%p)->(count=%lu)\n", This, This->ref);
1034 return IUnknown_AddRef(This->pUnkOuter);
1037 static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnRelease(IShellExecuteHookA* iface)
1039 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl, iface);
1041 TRACE("(%p)\n", This);
1043 return IUnknown_Release(This->pUnkOuter);
1046 static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA* iface, LPSHELLEXECUTEINFOA psei)
1048 ICOM_THIS(ICPanelImpl, iface);
1050 SHELLEXECUTEINFOA sei_tmp;
1051 PIDLCPanelStruct* pcpanel;
1052 char path[MAX_PATH];
1055 TRACE("(%p)->execute(%p)\n", This, psei);
1058 return E_INVALIDARG;
1060 pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
1063 return E_INVALIDARG;
1066 lstrcpyA(path+1, pcpanel->szName);
1068 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1069 lstrcatA(path, "\" ");
1070 lstrcatA(path, pcpanel->szName+pcpanel->offsDispName);
1072 memcpy(&sei_tmp, psei, sizeof(sei_tmp));
1073 sei_tmp.lpFile = path;
1074 sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
1076 ret = ShellExecuteExA(&sei_tmp);
1083 static ICOM_VTABLE(IShellExecuteHookA) vt_ShellExecuteHookA =
1085 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1087 IShellExecuteHookA_fnQueryInterface,
1088 IShellExecuteHookA_fnAddRef,
1089 IShellExecuteHookA_fnRelease,
1091 IShellExecuteHookA_fnExecute