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"
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 #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 an 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(LMEM_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 ICPanelImpl *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 ICPanelImpl *This = (ICPanelImpl *)iface;
184 ULONG refCount = InterlockedIncrement(&This->ref);
186 TRACE("(%p)->(count=%lu)\n", This, refCount - 1);
191 static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 * iface)
193 ICPanelImpl *This = (ICPanelImpl *)iface;
194 ULONG refCount = InterlockedDecrement(&This->ref);
196 TRACE("(%p)->(count=%lu)\n", This, refCount + 1);
199 TRACE("-- destroying IShellFolder(%p)\n", This);
201 SHFree(This->pidlRoot);
202 LocalFree((HLOCAL) This);
207 /**************************************************************************
208 * ISF_ControlPanel_fnParseDisplayName
210 static HRESULT WINAPI
211 ISF_ControlPanel_fnParseDisplayName(IShellFolder2 * iface,
214 LPOLESTR lpszDisplayName,
215 DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
217 ICPanelImpl *This = (ICPanelImpl *)iface;
219 HRESULT hr = E_INVALIDARG;
221 FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
222 This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes);
228 TRACE("(%p)->(-- ret=0x%08lx)\n", This, hr);
233 static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName,
234 LPCSTR comment, int iconIdx)
239 int size0 = (char*)&tmp.u.cpanel.szName-(char*)&tmp.u.cpanel;
243 tmp.type = PT_CPLAPPLET;
244 tmp.u.cpanel.dummy = 0;
245 tmp.u.cpanel.iconIdx = iconIdx;
250 tmp.u.cpanel.offsDispName = l+1;
251 l = strlen(displayName);
254 tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName+1+l;
258 pidl = SHAlloc(size+4);
262 pidl->mkid.cb = size+2;
263 memcpy(pidl->mkid.abID, &tmp, 2+size0);
265 p = &((PIDLDATA*)pidl->mkid.abID)->u.cpanel;
266 strcpy(p->szName, name);
267 strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
268 strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
270 *(WORD*)((char*)pidl+(size+2)) = 0;
277 /**************************************************************************
278 * _ILGetCPanelPointer()
279 * gets a pointer to the control panel struct stored in the pidl
281 static PIDLCPanelStruct* _ILGetCPanelPointer(LPCITEMIDLIST pidl)
283 LPPIDLDATA pdata = _ILGetDataPointer(pidl);
285 if (pdata && pdata->type==PT_CPLAPPLET)
286 return (PIDLCPanelStruct*)&(pdata->u.cpanel);
291 /**************************************************************************
292 * ISF_ControlPanel_fnEnumObjects
294 static BOOL SHELL_RegisterCPanelApp(IEnumIDList* list, LPCSTR path)
303 char displayName[MAX_PATH];
304 char comment[MAX_PATH];
306 WCHAR wpath[MAX_PATH];
308 MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
311 applet = Control_LoadApplet(0, wpath, &panel);
315 for(i=0; i<applet->count; ++i)
317 WideCharToMultiByte(CP_ACP, 0, applet->info[i].szName, -1, displayName, MAX_PATH, 0, 0);
318 WideCharToMultiByte(CP_ACP, 0, applet->info[i].szInfo, -1, comment, MAX_PATH, 0, 0);
320 applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info);
323 iconIdx = -info.idIcon; /* negative icon index instead of icon number */
327 pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx);
330 AddToEnumList(list, pidl);
332 Control_UnloadApplet(applet);
337 static int SHELL_RegisterRegistryCPanelApps(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
340 char value[MAX_PATH];
345 if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
351 DWORD nameLen = MAX_PATH;
352 DWORD valueLen = MAX_PATH;
354 if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value, &valueLen) != ERROR_SUCCESS)
357 if (SHELL_RegisterCPanelApp(list, value))
366 static int SHELL_RegisterCPanelFolders(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
373 if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
378 if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
383 LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name);
385 if (pidl && AddToEnumList(list, pidl))
396 /**************************************************************************
397 * CreateCPanelEnumList()
399 static BOOL CreateCPanelEnumList(
403 CHAR szPath[MAX_PATH];
404 WIN32_FIND_DATAA wfd;
407 TRACE("(%p)->(flags=0x%08lx) \n",iface,dwFlags);
409 /* enumerate control panel folders folders */
410 if (dwFlags & SHCONTF_FOLDERS)
411 SHELL_RegisterCPanelFolders(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
413 /* enumerate the control panel applets */
414 if (dwFlags & SHCONTF_NONFOLDERS)
418 GetSystemDirectoryA(szPath, MAX_PATH);
419 p = PathAddBackslashA(szPath);
422 TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface,debugstr_a(szPath));
423 hFile = FindFirstFileA(szPath, &wfd);
425 if (hFile != INVALID_HANDLE_VALUE)
429 if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
432 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
433 strcpy(p, wfd.cFileName);
434 SHELL_RegisterCPanelApp((IEnumIDList*)iface, szPath);
436 } while(FindNextFileA(hFile, &wfd));
440 SHELL_RegisterRegistryCPanelApps((IEnumIDList*)iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
441 SHELL_RegisterRegistryCPanelApps((IEnumIDList*)iface, HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
446 /**************************************************************************
447 * ISF_ControlPanel_fnEnumObjects
449 static HRESULT WINAPI
450 ISF_ControlPanel_fnEnumObjects(IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
452 ICPanelImpl *This = (ICPanelImpl *)iface;
454 TRACE("(%p)->(HWND=%p flags=0x%08lx pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
456 *ppEnumIDList = IEnumIDList_Constructor();
458 CreateCPanelEnumList(*ppEnumIDList, dwFlags);
460 TRACE("--(%p)->(new ID List: %p)\n", This, *ppEnumIDList);
462 return(*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
465 /**************************************************************************
466 * ISF_ControlPanel_fnBindToObject
468 static HRESULT WINAPI
469 ISF_ControlPanel_fnBindToObject(IShellFolder2 * iface, LPCITEMIDLIST pidl,
470 LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
472 ICPanelImpl *This = (ICPanelImpl *)iface;
474 TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
476 return SHELL32_BindToChild(This->pidlRoot, NULL, pidl, riid, ppvOut);
479 /**************************************************************************
480 * ISF_ControlPanel_fnBindToStorage
482 static HRESULT WINAPI
483 ISF_ControlPanel_fnBindToStorage(IShellFolder2 * iface,
484 LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
486 ICPanelImpl *This = (ICPanelImpl *)iface;
488 FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
494 /**************************************************************************
495 * ISF_ControlPanel_fnCompareIDs
498 static HRESULT WINAPI
499 ISF_ControlPanel_fnCompareIDs(IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
501 ICPanelImpl *This = (ICPanelImpl *)iface;
505 TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
506 nReturn = SHELL32_CompareIDs(_IShellFolder_(This), lParam, pidl1, pidl2);
507 TRACE("-- %i\n", nReturn);
511 /**************************************************************************
512 * ISF_ControlPanel_fnCreateViewObject
514 static HRESULT WINAPI
515 ISF_ControlPanel_fnCreateViewObject(IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
517 ICPanelImpl *This = (ICPanelImpl *)iface;
519 LPSHELLVIEW pShellView;
520 HRESULT hr = E_INVALIDARG;
522 TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid(riid), ppvOut);
527 if (IsEqualIID(riid, &IID_IDropTarget)) {
528 WARN("IDropTarget not implemented\n");
530 } else if (IsEqualIID(riid, &IID_IContextMenu)) {
531 WARN("IContextMenu not implemented\n");
533 } else if (IsEqualIID(riid, &IID_IShellView)) {
534 pShellView = IShellView_Constructor((IShellFolder *) iface);
536 hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
537 IShellView_Release(pShellView);
541 TRACE("--(%p)->(interface=%p)\n", This, ppvOut);
545 /**************************************************************************
546 * ISF_ControlPanel_fnGetAttributesOf
548 static HRESULT WINAPI
549 ISF_ControlPanel_fnGetAttributesOf(IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
551 ICPanelImpl *This = (ICPanelImpl *)iface;
555 TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08lx))\n",
556 This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
566 while(cidl > 0 && *apidl) {
568 SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
572 /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
573 *rgfInOut &= ~SFGAO_VALIDATE;
575 TRACE("-- result=0x%08lx\n", *rgfInOut);
579 /**************************************************************************
580 * ISF_ControlPanel_fnGetUIObjectOf
583 * HWND hwndOwner, //[in ] Parent window for any output
584 * UINT cidl, //[in ] array size
585 * LPCITEMIDLIST* apidl, //[in ] simple pidl array
586 * REFIID riid, //[in ] Requested Interface
587 * UINT* prgfInOut, //[ ] reserved
588 * LPVOID* ppvObject) //[out] Resulting Interface
591 static HRESULT WINAPI
592 ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 * iface,
594 UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
596 ICPanelImpl *This = (ICPanelImpl *)iface;
599 IUnknown *pObj = NULL;
600 HRESULT hr = E_INVALIDARG;
602 TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
603 This, hwndOwner, cidl, apidl, shdebugstr_guid(riid), prgfInOut, ppvOut);
608 if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
609 pObj = (LPUNKNOWN) ISvItemCm_Constructor((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
611 } else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
612 pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
614 } else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
615 pidl = ILCombine(This->pidlRoot, apidl[0]);
616 pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
619 } else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
620 pidl = ILCombine(This->pidlRoot, apidl[0]);
621 pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
624 } else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
626 pidl = ILCombine(This->pidlRoot, apidl[0]);
627 hr = IShellLink_ConstructFromFile(NULL, riid, pidl,(LPVOID*)&pObj);
633 if (SUCCEEDED(hr) && !pObj)
638 TRACE("(%p)->hr=0x%08lx\n", This, hr);
642 /**************************************************************************
643 * ISF_ControlPanel_fnGetDisplayNameOf
645 static HRESULT WINAPI ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
647 ICPanelImpl *This = (ICPanelImpl *)iface;
649 CHAR szPath[MAX_PATH*2];
650 PIDLCPanelStruct* pcpanel;
654 TRACE("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet);
657 if (!pidl || !strRet)
660 pcpanel = _ILGetCPanelPointer(pidl);
663 lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName);
665 if (!(dwFlags & SHGDN_FORPARSING))
666 FIXME("retrieve display name from control panel app\n");
668 /* take names of special folders only if its only this folder */
669 else if (_ILIsSpecialFolder(pidl)) {
670 BOOL bSimplePidl = _ILIsPidlSimple(pidl);
673 _ILSimpleGetText(pidl, szPath, MAX_PATH); /* append my own path */
675 FIXME("special pidl\n");
678 if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */
681 PathAddBackslashA(szPath); /*FIXME*/
682 len = lstrlenA(szPath);
685 (SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len)))
686 return E_OUTOFMEMORY;
690 strRet->uType = STRRET_CSTR;
691 lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
693 TRACE("--(%p)->(%s)\n", This, szPath);
697 /**************************************************************************
698 * ISF_ControlPanel_fnSetNameOf
699 * Changes the name of a file object or subfolder, possibly changing its item
700 * identifier in the process.
703 * HWND hwndOwner, //[in ] Owner window for output
704 * LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
705 * LPCOLESTR lpszName, //[in ] the items new display name
706 * DWORD dwFlags, //[in ] SHGNO formatting flags
707 * LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
709 static HRESULT WINAPI ISF_ControlPanel_fnSetNameOf(IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
710 LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
712 ICPanelImpl *This = (ICPanelImpl *)iface;
713 FIXME("(%p)->(%p,pidl=%p,%s,%lu,%p)\n", This, hwndOwner, pidl, debugstr_w(lpName), dwFlags, pPidlOut);
717 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2 * iface, GUID * pguid)
719 ICPanelImpl *This = (ICPanelImpl *)iface;
720 FIXME("(%p)\n", This);
723 static HRESULT WINAPI ISF_ControlPanel_fnEnumSearches(IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
725 ICPanelImpl *This = (ICPanelImpl *)iface;
726 FIXME("(%p)\n", This);
729 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
731 ICPanelImpl *This = (ICPanelImpl *)iface;
733 TRACE("(%p)\n", This);
735 if (pSort) *pSort = 0;
736 if (pDisplay) *pDisplay = 0;
739 static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
741 ICPanelImpl *This = (ICPanelImpl *)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, const SHCOLUMNID * pscid, VARIANT * pv)
751 ICPanelImpl *This = (ICPanelImpl *)iface;
752 FIXME("(%p)\n", This);
756 static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
758 ICPanelImpl *This = (ICPanelImpl *)iface;
761 TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
763 if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS)
767 psd->fmt = ControlPanelSFHeader[iColumn].fmt;
768 psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
769 psd->str.uType = STRRET_CSTR;
770 LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
773 psd->str.u.cStr[0] = 0x00;
774 psd->str.uType = STRRET_CSTR;
777 hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
779 case 1: /* comment */
780 _ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
788 static HRESULT WINAPI ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
790 ICPanelImpl *This = (ICPanelImpl *)iface;
791 FIXME("(%p)\n", This);
795 static const IShellFolder2Vtbl vt_ShellFolder2 =
798 ISF_ControlPanel_fnQueryInterface,
799 ISF_ControlPanel_fnAddRef,
800 ISF_ControlPanel_fnRelease,
801 ISF_ControlPanel_fnParseDisplayName,
802 ISF_ControlPanel_fnEnumObjects,
803 ISF_ControlPanel_fnBindToObject,
804 ISF_ControlPanel_fnBindToStorage,
805 ISF_ControlPanel_fnCompareIDs,
806 ISF_ControlPanel_fnCreateViewObject,
807 ISF_ControlPanel_fnGetAttributesOf,
808 ISF_ControlPanel_fnGetUIObjectOf,
809 ISF_ControlPanel_fnGetDisplayNameOf,
810 ISF_ControlPanel_fnSetNameOf,
813 ISF_ControlPanel_fnGetDefaultSearchGUID,
814 ISF_ControlPanel_fnEnumSearches,
815 ISF_ControlPanel_fnGetDefaultColumn,
816 ISF_ControlPanel_fnGetDefaultColumnState,
817 ISF_ControlPanel_fnGetDetailsEx,
818 ISF_ControlPanel_fnGetDetailsOf,
819 ISF_ControlPanel_fnMapColumnToSCID
822 /************************************************************************
823 * ICPanel_PersistFolder2_QueryInterface
825 static HRESULT WINAPI ICPanel_PersistFolder2_QueryInterface(IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObject)
827 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
829 TRACE("(%p)\n", This);
831 return IUnknown_QueryInterface(_IUnknown_(This), iid, ppvObject);
834 /************************************************************************
835 * ICPanel_PersistFolder2_AddRef
837 static ULONG WINAPI ICPanel_PersistFolder2_AddRef(IPersistFolder2 * iface)
839 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
841 TRACE("(%p)->(count=%lu)\n", This, This->ref);
843 return IUnknown_AddRef(_IUnknown_(This));
846 /************************************************************************
847 * ISFPersistFolder_Release
849 static ULONG WINAPI ICPanel_PersistFolder2_Release(IPersistFolder2 * iface)
851 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
853 TRACE("(%p)->(count=%lu)\n", This, This->ref);
855 return IUnknown_Release(_IUnknown_(This));
858 /************************************************************************
859 * ICPanel_PersistFolder2_GetClassID
861 static HRESULT WINAPI ICPanel_PersistFolder2_GetClassID(IPersistFolder2 * iface, CLSID * lpClassId)
863 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
865 TRACE("(%p)\n", This);
869 *lpClassId = CLSID_ControlPanel;
874 /************************************************************************
875 * ICPanel_PersistFolder2_Initialize
877 * NOTES: it makes no sense to change the pidl
879 static HRESULT WINAPI ICPanel_PersistFolder2_Initialize(IPersistFolder2 * iface, LPCITEMIDLIST pidl)
881 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
882 TRACE("(%p)->(%p)\n", This, pidl);
886 /**************************************************************************
887 * IPersistFolder2_fnGetCurFolder
889 static HRESULT WINAPI ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2 * iface, LPITEMIDLIST * pidl)
891 _ICOM_THIS_From_IPersistFolder2(ICPanelImpl, iface);
893 TRACE("(%p)->(%p)\n", This, pidl);
897 *pidl = ILClone(This->pidlRoot);
901 static const IPersistFolder2Vtbl vt_PersistFolder2 =
904 ICPanel_PersistFolder2_QueryInterface,
905 ICPanel_PersistFolder2_AddRef,
906 ICPanel_PersistFolder2_Release,
907 ICPanel_PersistFolder2_GetClassID,
908 ICPanel_PersistFolder2_Initialize,
909 ICPanel_PersistFolder2_GetCurFolder
912 HRESULT CPanel_GetIconLocationW(LPITEMIDLIST pidl,
913 LPWSTR szIconFile, UINT cchMax, int* piIndex)
915 PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
920 MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, szIconFile, cchMax);
921 *piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0;
927 /**************************************************************************
928 * IShellExecuteHookW Implementation
931 static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface(
932 IShellExecuteHookW* iface, REFIID riid, void** ppvObject)
934 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl, iface);
936 TRACE("(%p)->(count=%lu)\n", This, This->ref);
938 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
941 static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnAddRef(IShellExecuteHookW* iface)
943 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl, iface);
945 TRACE("(%p)->(count=%lu)\n", This, This->ref);
947 return IUnknown_AddRef(This->pUnkOuter);
950 static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnRelease(IShellExecuteHookW* iface)
952 _ICOM_THIS_From_IShellExecuteHookW(ICPanelImpl, iface);
954 TRACE("(%p)\n", This);
956 return IUnknown_Release(This->pUnkOuter);
959 static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW* iface, LPSHELLEXECUTEINFOW psei)
961 static const WCHAR wCplopen[] = {'c','p','l','o','p','e','n','\0'};
962 ICPanelImpl *This = (ICPanelImpl *)iface;
964 SHELLEXECUTEINFOW sei_tmp;
965 PIDLCPanelStruct* pcpanel;
966 WCHAR path[MAX_PATH];
970 TRACE("(%p)->execute(%p)\n", This, psei);
975 pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
981 /* Return value from MultiByteToWideChar includes terminating NUL, which
982 * compensates for the starting double quote we just put in */
983 l = MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, path+1, MAX_PATH);
985 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
989 MultiByteToWideChar(CP_ACP, 0, pcpanel->szName+pcpanel->offsDispName, -1, path+l, MAX_PATH);
991 memcpy(&sei_tmp, psei, sizeof(sei_tmp));
992 sei_tmp.lpFile = path;
993 sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
994 sei_tmp.lpVerb = wCplopen;
996 ret = ShellExecuteExW(&sei_tmp);
1003 static const IShellExecuteHookWVtbl vt_ShellExecuteHookW =
1006 IShellExecuteHookW_fnQueryInterface,
1007 IShellExecuteHookW_fnAddRef,
1008 IShellExecuteHookW_fnRelease,
1010 IShellExecuteHookW_fnExecute
1014 /**************************************************************************
1015 * IShellExecuteHookA Implementation
1018 static HRESULT WINAPI IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA* iface, REFIID riid, void** ppvObject)
1020 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl, iface);
1022 TRACE("(%p)->(count=%lu)\n", This, This->ref);
1024 return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
1027 static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnAddRef(IShellExecuteHookA* iface)
1029 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl, iface);
1031 TRACE("(%p)->(count=%lu)\n", This, This->ref);
1033 return IUnknown_AddRef(This->pUnkOuter);
1036 static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnRelease(IShellExecuteHookA* iface)
1038 _ICOM_THIS_From_IShellExecuteHookA(ICPanelImpl, iface);
1040 TRACE("(%p)\n", This);
1042 return IUnknown_Release(This->pUnkOuter);
1045 static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA* iface, LPSHELLEXECUTEINFOA psei)
1047 ICPanelImpl *This = (ICPanelImpl *)iface;
1049 SHELLEXECUTEINFOA sei_tmp;
1050 PIDLCPanelStruct* pcpanel;
1051 char path[MAX_PATH];
1054 TRACE("(%p)->execute(%p)\n", This, psei);
1057 return E_INVALIDARG;
1059 pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
1062 return E_INVALIDARG;
1065 lstrcpyA(path+1, pcpanel->szName);
1067 /* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
1068 lstrcatA(path, "\" ");
1069 lstrcatA(path, pcpanel->szName+pcpanel->offsDispName);
1071 memcpy(&sei_tmp, psei, sizeof(sei_tmp));
1072 sei_tmp.lpFile = path;
1073 sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
1075 ret = ShellExecuteExA(&sei_tmp);
1082 static const IShellExecuteHookAVtbl vt_ShellExecuteHookA =
1084 IShellExecuteHookA_fnQueryInterface,
1085 IShellExecuteHookA_fnAddRef,
1086 IShellExecuteHookA_fnRelease,
1087 IShellExecuteHookA_fnExecute