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 const 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=%u)\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=%u)\n", This, refCount + 1);
205 TRACE("-- destroying IShellFolder(%p)\n", This);
206 SHFree(This->pidlRoot);
207 LocalFree((HLOCAL) This);
212 /**************************************************************************
213 * ISF_ControlPanel_fnParseDisplayName
215 static HRESULT WINAPI
216 ISF_ControlPanel_fnParseDisplayName(IShellFolder2 * iface,
219 LPOLESTR lpszDisplayName,
220 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
222 ICPanelImpl *This = (ICPanelImpl *)iface;
224 HRESULT hr = E_INVALIDARG;
226 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
227 This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes);
233 TRACE("(%p)->(-- ret=0x%08x)\n", This, hr);
238 static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName,
239 LPCSTR comment, int iconIdx)
244 int size0 = (char*)&tmp.u.cpanel.szName-(char*)&tmp.u.cpanel;
248 tmp.type = PT_CPLAPPLET;
249 tmp.u.cpanel.dummy = 0;
250 tmp.u.cpanel.iconIdx = iconIdx;
255 tmp.u.cpanel.offsDispName = l+1;
256 l = strlen(displayName);
259 tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName+1+l;
263 pidl = SHAlloc(size+4);
267 pidl->mkid.cb = size+2;
268 memcpy(pidl->mkid.abID, &tmp, 2+size0);
270 p = &((PIDLDATA*)pidl->mkid.abID)->u.cpanel;
271 strcpy(p->szName, name);
272 strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
273 strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
275 *(WORD*)((char*)pidl+(size+2)) = 0;
282 /**************************************************************************
283 * _ILGetCPanelPointer()
284 * gets a pointer to the control panel struct stored in the pidl
286 static PIDLCPanelStruct* _ILGetCPanelPointer(LPCITEMIDLIST pidl)
288 LPPIDLDATA pdata = _ILGetDataPointer(pidl);
290 if (pdata && pdata->type==PT_CPLAPPLET)
291 return &pdata->u.cpanel;
296 /**************************************************************************
297 * ISF_ControlPanel_fnEnumObjects
299 static BOOL SHELL_RegisterCPanelApp(IEnumIDList* list, LPCSTR path)
308 char displayName[MAX_PATH];
309 char comment[MAX_PATH];
311 WCHAR wpath[MAX_PATH];
313 MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
316 applet = Control_LoadApplet(0, wpath, &panel);
320 for(i=0; i<applet->count; ++i)
322 WideCharToMultiByte(CP_ACP, 0, applet->info[i].szName, -1, displayName, MAX_PATH, 0, 0);
323 WideCharToMultiByte(CP_ACP, 0, applet->info[i].szInfo, -1, comment, MAX_PATH, 0, 0);
325 applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info);
328 iconIdx = -info.idIcon; /* negative icon index instead of icon number */
332 pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx);
335 AddToEnumList(list, pidl);
337 Control_UnloadApplet(applet);
342 static int SHELL_RegisterRegistryCPanelApps(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
345 char value[MAX_PATH];
350 if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
356 DWORD nameLen = MAX_PATH;
357 DWORD valueLen = MAX_PATH;
359 if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value, &valueLen) != ERROR_SUCCESS)
362 if (SHELL_RegisterCPanelApp(list, value))
371 static int SHELL_RegisterCPanelFolders(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
378 if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
383 if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
388 LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name);
390 if (pidl && AddToEnumList(list, pidl))
401 /**************************************************************************
402 * CreateCPanelEnumList()
404 static BOOL CreateCPanelEnumList(
408 CHAR szPath[MAX_PATH];
409 WIN32_FIND_DATAA wfd;
412 TRACE("(%p)->(flags=0x%08x)\n", iface, dwFlags);
414 /* enumerate control panel folders */
415 if (dwFlags & SHCONTF_FOLDERS)
416 SHELL_RegisterCPanelFolders(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
418 /* enumerate the control panel applets */
419 if (dwFlags & SHCONTF_NONFOLDERS)
423 GetSystemDirectoryA(szPath, MAX_PATH);
424 p = PathAddBackslashA(szPath);
427 TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface,debugstr_a(szPath));
428 hFile = FindFirstFileA(szPath, &wfd);
430 if (hFile != INVALID_HANDLE_VALUE)
434 if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
437 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
438 strcpy(p, wfd.cFileName);
439 SHELL_RegisterCPanelApp(iface, szPath);
441 } while(FindNextFileA(hFile, &wfd));
445 SHELL_RegisterRegistryCPanelApps(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
446 SHELL_RegisterRegistryCPanelApps(iface, HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
451 /**************************************************************************
452 * ISF_ControlPanel_fnEnumObjects
454 static HRESULT WINAPI
455 ISF_ControlPanel_fnEnumObjects(IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
457 ICPanelImpl *This = (ICPanelImpl *)iface;
459 TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
461 *ppEnumIDList = IEnumIDList_Constructor();
463 CreateCPanelEnumList(*ppEnumIDList, dwFlags);
465 TRACE("--(%p)->(new ID List: %p)\n", This, *ppEnumIDList);
467 return(*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
470 /**************************************************************************
471 * ISF_ControlPanel_fnBindToObject
473 static HRESULT WINAPI
474 ISF_ControlPanel_fnBindToObject(IShellFolder2 * iface, LPCITEMIDLIST pidl,
475 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
477 ICPanelImpl *This = (ICPanelImpl *)iface;
479 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
481 return SHELL32_BindToChild(This->pidlRoot, NULL, pidl, riid, ppvOut);
484 /**************************************************************************
485 * ISF_ControlPanel_fnBindToStorage
487 static HRESULT WINAPI
488 ISF_ControlPanel_fnBindToStorage(IShellFolder2 * iface,
489 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
491 ICPanelImpl *This = (ICPanelImpl *)iface;
493 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
499 /**************************************************************************
500 * ISF_ControlPanel_fnCompareIDs
503 static HRESULT WINAPI
504 ISF_ControlPanel_fnCompareIDs(IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
506 ICPanelImpl *This = (ICPanelImpl *)iface;
510 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
511 nReturn = SHELL32_CompareIDs(_IShellFolder_(This), lParam, pidl1, pidl2);
512 TRACE("-- %i\n", nReturn);
516 /**************************************************************************
517 * ISF_ControlPanel_fnCreateViewObject
519 static HRESULT WINAPI
520 ISF_ControlPanel_fnCreateViewObject(IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
522 ICPanelImpl *This = (ICPanelImpl *)iface;
524 LPSHELLVIEW pShellView;
525 HRESULT hr = E_INVALIDARG;
527 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid(riid), ppvOut);
532 if (IsEqualIID(riid, &IID_IDropTarget)) {
533 WARN("IDropTarget not implemented\n");
535 } else if (IsEqualIID(riid, &IID_IContextMenu)) {
536 WARN("IContextMenu not implemented\n");
538 } else if (IsEqualIID(riid, &IID_IShellView)) {
539 pShellView = IShellView_Constructor((IShellFolder *) iface);
541 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
542 IShellView_Release(pShellView);
546 TRACE("--(%p)->(interface=%p)\n", This, ppvOut);
550 /**************************************************************************
551 * ISF_ControlPanel_fnGetAttributesOf
553 static HRESULT WINAPI
554 ISF_ControlPanel_fnGetAttributesOf(IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
556 ICPanelImpl *This = (ICPanelImpl *)iface;
560 TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
561 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
571 while(cidl > 0 && *apidl) {
573 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
577 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
578 *rgfInOut &= ~SFGAO_VALIDATE;
580 TRACE("-- result=0x%08x\n", *rgfInOut);
584 /**************************************************************************
585 * ISF_ControlPanel_fnGetUIObjectOf
588 * HWND hwndOwner, //[in ] Parent window for any output
589 * UINT cidl, //[in ] array size
590 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
591 * REFIID riid, //[in ] Requested Interface
592 * UINT* prgfInOut, //[ ] reserved
593 * LPVOID* ppvObject) //[out] Resulting Interface
596 static HRESULT WINAPI
597 ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 * iface,
599 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
601 ICPanelImpl *This = (ICPanelImpl *)iface;
604 IUnknown *pObj = NULL;
605 HRESULT hr = E_INVALIDARG;
607 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
608 This, hwndOwner, cidl, apidl, shdebugstr_guid(riid), prgfInOut, ppvOut);
613 if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
614 pObj = (LPUNKNOWN) ISvItemCm_Constructor((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
616 } else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
617 pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
619 } else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
620 pidl = ILCombine(This->pidlRoot, apidl[0]);
621 pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
624 } else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
625 pidl = ILCombine(This->pidlRoot, apidl[0]);
626 pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
629 } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
631 pidl = ILCombine(This->pidlRoot, apidl[0]);
632 hr = IShellLink_ConstructFromFile(NULL, riid, pidl,(LPVOID*)&pObj);
638 if (SUCCEEDED(hr) && !pObj)
643 TRACE("(%p)->hr=0x%08x\n", This, hr);
647 /**************************************************************************
648 * ISF_ControlPanel_fnGetDisplayNameOf
650 static HRESULT WINAPI ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
652 ICPanelImpl *This = (ICPanelImpl *)iface;
654 CHAR szPath[MAX_PATH];
655 WCHAR wszPath[MAX_PATH+1]; /* +1 for potential backslash */
656 PIDLCPanelStruct* pcpanel;
660 TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
663 if (!pidl || !strRet)
666 pcpanel = _ILGetCPanelPointer(pidl);
669 lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName);
671 if (!(dwFlags & SHGDN_FORPARSING))
672 FIXME("retrieve display name from control panel app\n");
674 /* take names of special folders only if it's only this folder */
675 else if (_ILIsSpecialFolder(pidl)) {
676 BOOL bSimplePidl = _ILIsPidlSimple(pidl);
679 _ILSimpleGetTextW(pidl, wszPath, MAX_PATH); /* append my own path */
681 FIXME("special pidl\n");
684 if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */
687 PathAddBackslashW(wszPath);
688 len = lstrlenW(wszPath);
691 (SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, wszPath + len, MAX_PATH + 1 - len)))
692 return E_OUTOFMEMORY;
693 if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL))
698 strRet->uType = STRRET_CSTR;
699 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
701 TRACE("--(%p)->(%s)\n", This, szPath);
705 /**************************************************************************
706 * ISF_ControlPanel_fnSetNameOf
707 * Changes the name of a file object or subfolder, possibly changing its item
708 * identifier in the process.
711 * HWND hwndOwner, //[in ] Owner window for output
712 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
713 * LPCOLESTR lpszName, //[in ] the items new display name
714 * DWORD dwFlags, //[in ] SHGNO formatting flags
715 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
717 static HRESULT WINAPI ISF_ControlPanel_fnSetNameOf(IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
718 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
720 ICPanelImpl *This = (ICPanelImpl *)iface;
721 FIXME("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl, debugstr_w(lpName), dwFlags, pPidlOut);
725 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2 * iface, GUID * pguid)
727 ICPanelImpl *This = (ICPanelImpl *)iface;
728 FIXME("(%p)\n", This);
731 static HRESULT WINAPI ISF_ControlPanel_fnEnumSearches(IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
733 ICPanelImpl *This = (ICPanelImpl *)iface;
734 FIXME("(%p)\n", This);
737 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
739 ICPanelImpl *This = (ICPanelImpl *)iface;
741 TRACE("(%p)\n", This);
743 if (pSort) *pSort = 0;
744 if (pDisplay) *pDisplay = 0;
747 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
749 ICPanelImpl *This = (ICPanelImpl *)iface;
751 TRACE("(%p)\n", This);
753 if (!pcsFlags || iColumn >= CONROLPANELSHELLVIEWCOLUMNS) return E_INVALIDARG;
754 *pcsFlags = ControlPanelSFHeader[iColumn].pcsFlags;
757 static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsEx(IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
759 ICPanelImpl *This = (ICPanelImpl *)iface;
760 FIXME("(%p)\n", This);
764 static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
766 ICPanelImpl *This = (ICPanelImpl *)iface;
769 TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
771 if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS)
775 psd->fmt = ControlPanelSFHeader[iColumn].fmt;
776 psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
777 psd->str.uType = STRRET_CSTR;
778 LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
781 psd->str.u.cStr[0] = 0x00;
782 psd->str.uType = STRRET_CSTR;
785 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
787 case 1: /* comment */
788 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
796 static HRESULT WINAPI ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
798 ICPanelImpl *This = (ICPanelImpl *)iface;
799 FIXME("(%p)\n", This);
803 static const IShellFolder2Vtbl vt_ShellFolder2 =
806 ISF_ControlPanel_fnQueryInterface,
807 ISF_ControlPanel_fnAddRef,
808 ISF_ControlPanel_fnRelease,
809 ISF_ControlPanel_fnParseDisplayName,
810 ISF_ControlPanel_fnEnumObjects,
811 ISF_ControlPanel_fnBindToObject,
812 ISF_ControlPanel_fnBindToStorage,
813 ISF_ControlPanel_fnCompareIDs,
814 ISF_ControlPanel_fnCreateViewObject,
815 ISF_ControlPanel_fnGetAttributesOf,
816 ISF_ControlPanel_fnGetUIObjectOf,
817 ISF_ControlPanel_fnGetDisplayNameOf,
818 ISF_ControlPanel_fnSetNameOf,
821 ISF_ControlPanel_fnGetDefaultSearchGUID,
822 ISF_ControlPanel_fnEnumSearches,
823 ISF_ControlPanel_fnGetDefaultColumn,
824 ISF_ControlPanel_fnGetDefaultColumnState,
825 ISF_ControlPanel_fnGetDetailsEx,
826 ISF_ControlPanel_fnGetDetailsOf,
827 ISF_ControlPanel_fnMapColumnToSCID
830 /************************************************************************
831 * ICPanel_PersistFolder2_QueryInterface
833 static HRESULT WINAPI ICPanel_PersistFolder2_QueryInterface(IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObject)
835 ICPanelImpl *This = impl_from_IPersistFolder2(iface);
837 TRACE("(%p)\n", This);
839 return IUnknown_QueryInterface(_IUnknown_(This), iid, ppvObject);
842 /************************************************************************
843 * ICPanel_PersistFolder2_AddRef
845 static ULONG WINAPI ICPanel_PersistFolder2_AddRef(IPersistFolder2 * iface)
847 ICPanelImpl *This = impl_from_IPersistFolder2(iface);
849 TRACE("(%p)->(count=%u)\n", This, This->ref);
851 return IUnknown_AddRef(_IUnknown_(This));
854 /************************************************************************
855 * ISFPersistFolder_Release
857 static ULONG WINAPI ICPanel_PersistFolder2_Release(IPersistFolder2 * iface)
859 ICPanelImpl *This = impl_from_IPersistFolder2(iface);
861 TRACE("(%p)->(count=%u)\n", This, This->ref);
863 return IUnknown_Release(_IUnknown_(This));
866 /************************************************************************
867 * ICPanel_PersistFolder2_GetClassID
869 static HRESULT WINAPI ICPanel_PersistFolder2_GetClassID(IPersistFolder2 * iface, CLSID * lpClassId)
871 ICPanelImpl *This = impl_from_IPersistFolder2(iface);
873 TRACE("(%p)\n", This);
877 *lpClassId = CLSID_ControlPanel;
882 /************************************************************************
883 * ICPanel_PersistFolder2_Initialize
885 * NOTES: it makes no sense to change the pidl
887 static HRESULT WINAPI ICPanel_PersistFolder2_Initialize(IPersistFolder2 * iface, LPCITEMIDLIST pidl)
889 ICPanelImpl *This = impl_from_IPersistFolder2(iface);
890 TRACE("(%p)->(%p)\n", This, pidl);
894 /**************************************************************************
895 * IPersistFolder2_fnGetCurFolder
897 static HRESULT WINAPI ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2 * iface, LPITEMIDLIST * pidl)
899 ICPanelImpl *This = impl_from_IPersistFolder2(iface);
901 TRACE("(%p)->(%p)\n", This, pidl);
905 *pidl = ILClone(This->pidlRoot);
909 static const IPersistFolder2Vtbl vt_PersistFolder2 =
912 ICPanel_PersistFolder2_QueryInterface,
913 ICPanel_PersistFolder2_AddRef,
914 ICPanel_PersistFolder2_Release,
915 ICPanel_PersistFolder2_GetClassID,
916 ICPanel_PersistFolder2_Initialize,
917 ICPanel_PersistFolder2_GetCurFolder
920 HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST pidl,
921 LPWSTR szIconFile, UINT cchMax, int* piIndex)
923 PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
928 MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, szIconFile, cchMax);
929 *piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0;
935 /**************************************************************************
936 * IShellExecuteHookW Implementation
939 static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface(
940 IShellExecuteHookW* iface, REFIID riid, void** ppvObject)
942 ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
944 TRACE("(%p)->(count=%u)\n", This, This->ref);
946 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
949 static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnAddRef(IShellExecuteHookW* iface)
951 ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
953 TRACE("(%p)->(count=%u)\n", This, This->ref);
955 return IUnknown_AddRef(This->pUnkOuter);
958 static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnRelease(IShellExecuteHookW* iface)
960 ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
962 TRACE("(%p)\n", This);
964 return IUnknown_Release(This->pUnkOuter);
967 static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW* iface, LPSHELLEXECUTEINFOW psei)
969 static const WCHAR wCplopen[] = {'c','p','l','o','p','e','n','\0'};
970 ICPanelImpl *This = (ICPanelImpl *)iface;
972 SHELLEXECUTEINFOW sei_tmp;
973 PIDLCPanelStruct* pcpanel;
974 WCHAR path[MAX_PATH];
975 WCHAR params[MAX_PATH];
979 TRACE("(%p)->execute(%p)\n", This, psei);
984 pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
990 /* Return value from MultiByteToWideChar includes terminating NUL, which
991 * compensates for the starting double quote we just put in */
992 l = MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, path+1, MAX_PATH);
994 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
998 MultiByteToWideChar(CP_ACP, 0, pcpanel->szName+pcpanel->offsDispName, -1, params, MAX_PATH);
1001 sei_tmp.lpFile = path;
1002 sei_tmp.lpParameters = params;
1003 sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
1004 sei_tmp.lpVerb = wCplopen;
1006 ret = ShellExecuteExW(&sei_tmp);
1013 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW =
1016 IShellExecuteHookW_fnQueryInterface,
1017 IShellExecuteHookW_fnAddRef,
1018 IShellExecuteHookW_fnRelease,
1020 IShellExecuteHookW_fnExecute
1024 /**************************************************************************
1025 * IShellExecuteHookA Implementation
1028 static HRESULT WINAPI IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA* iface, REFIID riid, void** ppvObject)
1030 ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
1032 TRACE("(%p)->(count=%u)\n", This, This->ref);
1034 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
1037 static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnAddRef(IShellExecuteHookA* iface)
1039 ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
1041 TRACE("(%p)->(count=%u)\n", This, This->ref);
1043 return IUnknown_AddRef(This->pUnkOuter);
1046 static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnRelease(IShellExecuteHookA* iface)
1048 ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
1050 TRACE("(%p)\n", This);
1052 return IUnknown_Release(This->pUnkOuter);
1055 static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA* iface, LPSHELLEXECUTEINFOA psei)
1057 ICPanelImpl *This = (ICPanelImpl *)iface;
1059 SHELLEXECUTEINFOA sei_tmp;
1060 PIDLCPanelStruct* pcpanel;
1061 char path[MAX_PATH];
1064 TRACE("(%p)->execute(%p)\n", This, psei);
1067 return E_INVALIDARG;
1069 pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
1072 return E_INVALIDARG;
1075 lstrcpyA(path+1, pcpanel->szName);
1077 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1078 lstrcatA(path, "\" ");
1079 lstrcatA(path, pcpanel->szName+pcpanel->offsDispName);
1082 sei_tmp.lpFile = path;
1083 sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
1085 ret = ShellExecuteExA(&sei_tmp);
1092 static const IShellExecuteHookAVtbl vt_ShellExecuteHookA =
1094 IShellExecuteHookA_fnQueryInterface,
1095 IShellExecuteHookA_fnAddRef,
1096 IShellExecuteHookA_fnRelease,
1097 IShellExecuteHookA_fnExecute