2004-03-27 02:42:22 +01:00
|
|
|
/*
|
|
|
|
* Control panel folder
|
|
|
|
*
|
|
|
|
* Copyright 2003 Martin Fuchs
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2007-05-04 12:08:15 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2004-03-27 02:42:22 +01:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-03-27 02:42:22 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2004-03-27 02:42:22 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "shlguid.h"
|
|
|
|
|
2008-07-24 23:10:33 +02:00
|
|
|
#include "commctrl.h"
|
2004-04-08 06:37:43 +02:00
|
|
|
#include "cpanel.h"
|
|
|
|
#include "enumidlist.h"
|
2004-03-27 02:42:22 +01:00
|
|
|
#include "pidl.h"
|
|
|
|
#include "undocshell.h"
|
|
|
|
#include "shell32_main.h"
|
|
|
|
#include "shresdef.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "debughlp.h"
|
|
|
|
#include "shfldr.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* control panel implementation in shell namespace
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
2005-06-06 21:50:35 +02:00
|
|
|
const IShellFolder2Vtbl *lpVtbl;
|
2005-07-03 14:03:35 +02:00
|
|
|
LONG ref;
|
2005-06-06 21:50:35 +02:00
|
|
|
const IPersistFolder2Vtbl *lpVtblPersistFolder2;
|
|
|
|
const IShellExecuteHookWVtbl *lpVtblShellExecuteHookW;
|
|
|
|
const IShellExecuteHookAVtbl *lpVtblShellExecuteHookA;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
IUnknown *pUnkOuter; /* used for aggregation */
|
|
|
|
|
|
|
|
/* both paths are parsible from the desktop */
|
|
|
|
LPITEMIDLIST pidlRoot; /* absolute pidl */
|
|
|
|
int dwAttributes; /* attributes returned by GetAttributesOf FIXME: use it */
|
|
|
|
} ICPanelImpl;
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IShellFolder2Vtbl vt_ShellFolder2;
|
|
|
|
static const IPersistFolder2Vtbl vt_PersistFolder2;
|
|
|
|
static const IShellExecuteHookWVtbl vt_ShellExecuteHookW;
|
|
|
|
static const IShellExecuteHookAVtbl vt_ShellExecuteHookA;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
static inline ICPanelImpl *impl_from_IPersistFolder2( IPersistFolder2 *iface )
|
|
|
|
{
|
|
|
|
return (ICPanelImpl *)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblPersistFolder2));
|
|
|
|
}
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
static inline ICPanelImpl *impl_from_IShellExecuteHookW( IShellExecuteHookW *iface )
|
|
|
|
{
|
|
|
|
return (ICPanelImpl *)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblShellExecuteHookW));
|
|
|
|
}
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2005-07-27 13:10:52 +02:00
|
|
|
static inline ICPanelImpl *impl_from_IShellExecuteHookA( IShellExecuteHookA *iface )
|
|
|
|
{
|
|
|
|
return (ICPanelImpl *)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblShellExecuteHookA));
|
|
|
|
}
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-03-23 14:15:18 +01:00
|
|
|
converts This to an interface pointer
|
2004-03-27 02:42:22 +01:00
|
|
|
*/
|
2009-02-18 22:45:59 +01:00
|
|
|
#define _IUnknown_(This) ((IUnknown*)&(This)->lpVtbl)
|
|
|
|
#define _IShellFolder_(This) ((IShellFolder*)&(This)->lpVtbl)
|
|
|
|
#define _IShellFolder2_(This) (&(This)->lpVtbl)
|
|
|
|
|
|
|
|
#define _IPersist_(This) (&(This)->lpVtblPersistFolder2)
|
|
|
|
#define _IPersistFolder_(This) (&(This)->lpVtblPersistFolder2)
|
|
|
|
#define _IPersistFolder2_(This) (&(This)->lpVtblPersistFolder2)
|
|
|
|
#define _IShellExecuteHookW_(This) (&(This)->lpVtblShellExecuteHookW)
|
|
|
|
#define _IShellExecuteHookA_(This) (&(This)->lpVtblShellExecuteHookA)
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IShellFolder [ControlPanel] implementation
|
|
|
|
*/
|
|
|
|
|
2006-11-28 11:38:58 +01:00
|
|
|
static const shvheader ControlPanelSFHeader[] = {
|
2004-03-27 02:42:22 +01:00
|
|
|
{IDS_SHV_COLUMN8, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_RIGHT, 15},/*FIXME*/
|
2008-06-23 19:54:20 +02:00
|
|
|
{IDS_SHV_COLUMN9, SHCOLSTATE_TYPE_STR | SHCOLSTATE_ONBYDEFAULT, LVCFMT_LEFT, 80},/*FIXME*/
|
2004-03-27 02:42:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#define CONROLPANELSHELLVIEWCOLUMNS 2
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IControlPanel_Constructor
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOID * ppv)
|
|
|
|
{
|
|
|
|
ICPanelImpl *sf;
|
|
|
|
|
|
|
|
TRACE("unkOut=%p %s\n", pUnkOuter, shdebugstr_guid(riid));
|
|
|
|
|
|
|
|
if (!ppv)
|
|
|
|
return E_POINTER;
|
|
|
|
if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2008-11-05 23:00:50 +01:00
|
|
|
sf = LocalAlloc(LMEM_ZEROINIT, sizeof(ICPanelImpl));
|
2004-03-27 02:42:22 +01:00
|
|
|
if (!sf)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
sf->ref = 0;
|
|
|
|
sf->lpVtbl = &vt_ShellFolder2;
|
|
|
|
sf->lpVtblPersistFolder2 = &vt_PersistFolder2;
|
|
|
|
sf->lpVtblShellExecuteHookW = &vt_ShellExecuteHookW;
|
|
|
|
sf->lpVtblShellExecuteHookA = &vt_ShellExecuteHookA;
|
2004-04-07 21:45:48 +02:00
|
|
|
sf->pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */
|
2004-03-27 02:42:22 +01:00
|
|
|
sf->pUnkOuter = pUnkOuter ? pUnkOuter : _IUnknown_ (sf);
|
|
|
|
|
2008-10-08 01:32:38 +02:00
|
|
|
if (FAILED(IUnknown_QueryInterface(_IUnknown_(sf), riid, ppv))) {
|
2004-03-27 02:42:22 +01:00
|
|
|
IUnknown_Release(_IUnknown_(sf));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("--(%p)\n", sf);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnQueryInterface
|
|
|
|
*
|
|
|
|
* NOTES supports not IPersist/IPersistFolder
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnQueryInterface(IShellFolder2 * iface, REFIID riid, LPVOID * ppvObject)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s,%p)\n", This, shdebugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IShellFolder) || IsEqualIID(riid, &IID_IShellFolder2))
|
|
|
|
*ppvObject = This;
|
|
|
|
else if (IsEqualIID(riid, &IID_IPersist) ||
|
|
|
|
IsEqualIID(riid, &IID_IPersistFolder) || IsEqualIID(riid, &IID_IPersistFolder2))
|
|
|
|
*ppvObject = _IPersistFolder2_(This);
|
|
|
|
else if (IsEqualIID(riid, &IID_IShellExecuteHookW))
|
|
|
|
*ppvObject = _IShellExecuteHookW_(This);
|
|
|
|
else if (IsEqualIID(riid, &IID_IShellExecuteHookA))
|
|
|
|
*ppvObject = _IShellExecuteHookA_(This);
|
|
|
|
|
|
|
|
if (*ppvObject) {
|
|
|
|
IUnknown_AddRef((IUnknown *)(*ppvObject));
|
|
|
|
TRACE("-- Interface:(%p)->(%p)\n", ppvObject, *ppvObject);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
TRACE("-- Interface: E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ISF_ControlPanel_fnAddRef(IShellFolder2 * iface)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, refCount - 1);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2004-03-27 02:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ISF_ControlPanel_fnRelease(IShellFolder2 * iface)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, refCount + 1);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
if (!refCount) {
|
2004-03-27 02:42:22 +01:00
|
|
|
TRACE("-- destroying IShellFolder(%p)\n", This);
|
2006-10-07 03:06:26 +02:00
|
|
|
SHFree(This->pidlRoot);
|
2009-02-18 22:46:39 +01:00
|
|
|
LocalFree(This);
|
2004-03-27 02:42:22 +01:00
|
|
|
}
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2004-03-27 02:42:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnParseDisplayName
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnParseDisplayName(IShellFolder2 * iface,
|
|
|
|
HWND hwndOwner,
|
|
|
|
LPBC pbc,
|
|
|
|
LPOLESTR lpszDisplayName,
|
|
|
|
DWORD * pchEaten, LPITEMIDLIST * ppidl, DWORD * pdwAttributes)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
FIXME("(%p)->(HWND=%p,%p,%p=%s,%p,pidl=%p,%p)\n",
|
|
|
|
This, hwndOwner, pbc, lpszDisplayName, debugstr_w(lpszDisplayName), pchEaten, ppidl, pdwAttributes);
|
|
|
|
|
|
|
|
*ppidl = 0;
|
|
|
|
if (pchEaten)
|
|
|
|
*pchEaten = 0;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(-- ret=0x%08x)\n", This, hr);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2004-04-08 06:37:43 +02:00
|
|
|
static LPITEMIDLIST _ILCreateCPanelApplet(LPCSTR name, LPCSTR displayName,
|
|
|
|
LPCSTR comment, int iconIdx)
|
|
|
|
{
|
|
|
|
PIDLCPanelStruct *p;
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
PIDLDATA tmp;
|
2008-07-14 19:44:17 +02:00
|
|
|
int size0 = (char*)tmp.u.cpanel.szName-(char*)&tmp.u.cpanel;
|
2004-04-08 06:37:43 +02:00
|
|
|
int size = size0;
|
|
|
|
int l;
|
|
|
|
|
2004-04-14 21:33:07 +02:00
|
|
|
tmp.type = PT_CPLAPPLET;
|
2004-04-08 06:37:43 +02:00
|
|
|
tmp.u.cpanel.dummy = 0;
|
|
|
|
tmp.u.cpanel.iconIdx = iconIdx;
|
|
|
|
|
|
|
|
l = strlen(name);
|
|
|
|
size += l+1;
|
|
|
|
|
|
|
|
tmp.u.cpanel.offsDispName = l+1;
|
|
|
|
l = strlen(displayName);
|
|
|
|
size += l+1;
|
|
|
|
|
|
|
|
tmp.u.cpanel.offsComment = tmp.u.cpanel.offsDispName+1+l;
|
|
|
|
l = strlen(comment);
|
|
|
|
size += l+1;
|
|
|
|
|
|
|
|
pidl = SHAlloc(size+4);
|
|
|
|
if (!pidl)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pidl->mkid.cb = size+2;
|
|
|
|
memcpy(pidl->mkid.abID, &tmp, 2+size0);
|
|
|
|
|
|
|
|
p = &((PIDLDATA*)pidl->mkid.abID)->u.cpanel;
|
|
|
|
strcpy(p->szName, name);
|
|
|
|
strcpy(p->szName+tmp.u.cpanel.offsDispName, displayName);
|
|
|
|
strcpy(p->szName+tmp.u.cpanel.offsComment, comment);
|
|
|
|
|
|
|
|
*(WORD*)((char*)pidl+(size+2)) = 0;
|
|
|
|
|
|
|
|
pcheck(pidl);
|
|
|
|
|
|
|
|
return pidl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* _ILGetCPanelPointer()
|
|
|
|
* gets a pointer to the control panel struct stored in the pidl
|
|
|
|
*/
|
|
|
|
static PIDLCPanelStruct* _ILGetCPanelPointer(LPCITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
LPPIDLDATA pdata = _ILGetDataPointer(pidl);
|
|
|
|
|
2004-04-14 21:33:07 +02:00
|
|
|
if (pdata && pdata->type==PT_CPLAPPLET)
|
2008-01-19 17:54:24 +01:00
|
|
|
return &pdata->u.cpanel;
|
2004-04-08 06:37:43 +02:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnEnumObjects
|
|
|
|
*/
|
|
|
|
static BOOL SHELL_RegisterCPanelApp(IEnumIDList* list, LPCSTR path)
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
CPlApplet* applet;
|
|
|
|
CPanel panel;
|
|
|
|
CPLINFO info;
|
|
|
|
unsigned i;
|
|
|
|
int iconIdx;
|
|
|
|
|
|
|
|
char displayName[MAX_PATH];
|
|
|
|
char comment[MAX_PATH];
|
|
|
|
|
|
|
|
WCHAR wpath[MAX_PATH];
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, path, -1, wpath, MAX_PATH);
|
|
|
|
|
|
|
|
panel.first = NULL;
|
|
|
|
applet = Control_LoadApplet(0, wpath, &panel);
|
|
|
|
|
|
|
|
if (applet)
|
|
|
|
{
|
|
|
|
for(i=0; i<applet->count; ++i)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, applet->info[i].szName, -1, displayName, MAX_PATH, 0, 0);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, applet->info[i].szInfo, -1, comment, MAX_PATH, 0, 0);
|
|
|
|
|
|
|
|
applet->proc(0, CPL_INQUIRE, i, (LPARAM)&info);
|
|
|
|
|
|
|
|
if (info.idIcon > 0)
|
|
|
|
iconIdx = -info.idIcon; /* negative icon index instead of icon number */
|
|
|
|
else
|
|
|
|
iconIdx = 0;
|
|
|
|
|
|
|
|
pidl = _ILCreateCPanelApplet(path, displayName, comment, iconIdx);
|
|
|
|
|
|
|
|
if (pidl)
|
|
|
|
AddToEnumList(list, pidl);
|
|
|
|
}
|
|
|
|
Control_UnloadApplet(applet);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int SHELL_RegisterRegistryCPanelApps(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
|
|
|
|
{
|
|
|
|
char name[MAX_PATH];
|
|
|
|
char value[MAX_PATH];
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
for(;; ++idx)
|
|
|
|
{
|
|
|
|
DWORD nameLen = MAX_PATH;
|
|
|
|
DWORD valueLen = MAX_PATH;
|
|
|
|
|
2008-07-14 19:44:17 +02:00
|
|
|
if (RegEnumValueA(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)value, &valueLen) != ERROR_SUCCESS)
|
2004-04-08 06:37:43 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (SHELL_RegisterCPanelApp(list, value))
|
|
|
|
++cnt;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int SHELL_RegisterCPanelFolders(IEnumIDList* list, HKEY hkey_root, LPCSTR szRepPath)
|
|
|
|
{
|
|
|
|
char name[MAX_PATH];
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
if (RegOpenKeyA(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
int idx = 0;
|
|
|
|
for(;; ++idx)
|
|
|
|
{
|
|
|
|
if (RegEnumKeyA(hkey, idx, name, MAX_PATH) != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (*name == '{')
|
|
|
|
{
|
|
|
|
LPITEMIDLIST pidl = _ILCreateGuidFromStrA(name);
|
|
|
|
|
|
|
|
if (pidl && AddToEnumList(list, pidl))
|
|
|
|
++cnt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* CreateCPanelEnumList()
|
|
|
|
*/
|
|
|
|
static BOOL CreateCPanelEnumList(
|
|
|
|
IEnumIDList * iface,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
CHAR szPath[MAX_PATH];
|
|
|
|
WIN32_FIND_DATAA wfd;
|
|
|
|
HANDLE hFile;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(flags=0x%08x)\n", iface, dwFlags);
|
2004-04-08 06:37:43 +02:00
|
|
|
|
2006-11-07 00:37:42 +01:00
|
|
|
/* enumerate control panel folders */
|
2004-04-08 06:37:43 +02:00
|
|
|
if (dwFlags & SHCONTF_FOLDERS)
|
|
|
|
SHELL_RegisterCPanelFolders(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace");
|
|
|
|
|
|
|
|
/* enumerate the control panel applets */
|
|
|
|
if (dwFlags & SHCONTF_NONFOLDERS)
|
|
|
|
{
|
|
|
|
LPSTR p;
|
|
|
|
|
|
|
|
GetSystemDirectoryA(szPath, MAX_PATH);
|
|
|
|
p = PathAddBackslashA(szPath);
|
|
|
|
strcpy(p, "*.cpl");
|
|
|
|
|
|
|
|
TRACE("-- (%p)-> enumerate SHCONTF_NONFOLDERS of %s\n",iface,debugstr_a(szPath));
|
|
|
|
hFile = FindFirstFileA(szPath, &wfd);
|
|
|
|
|
|
|
|
if (hFile != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(dwFlags & SHCONTF_INCLUDEHIDDEN) && (wfd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
|
|
|
strcpy(p, wfd.cFileName);
|
2008-01-19 17:54:24 +01:00
|
|
|
SHELL_RegisterCPanelApp(iface, szPath);
|
2004-04-08 06:37:43 +02:00
|
|
|
}
|
|
|
|
} while(FindNextFileA(hFile, &wfd));
|
|
|
|
FindClose(hFile);
|
|
|
|
}
|
|
|
|
|
2008-01-19 17:54:24 +01:00
|
|
|
SHELL_RegisterRegistryCPanelApps(iface, HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
|
|
|
SHELL_RegisterRegistryCPanelApps(iface, HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
2004-04-08 06:37:43 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnEnumObjects
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnEnumObjects(IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST * ppEnumIDList)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", This, hwndOwner, dwFlags, ppEnumIDList);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2004-04-08 06:37:43 +02:00
|
|
|
*ppEnumIDList = IEnumIDList_Constructor();
|
|
|
|
if (*ppEnumIDList)
|
|
|
|
CreateCPanelEnumList(*ppEnumIDList, dwFlags);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("--(%p)->(new ID List: %p)\n", This, *ppEnumIDList);
|
|
|
|
|
|
|
|
return(*ppEnumIDList) ? S_OK : E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnBindToObject
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnBindToObject(IShellFolder2 * iface, LPCITEMIDLIST pidl,
|
|
|
|
LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
|
|
|
|
|
|
|
|
return SHELL32_BindToChild(This->pidlRoot, NULL, pidl, riid, ppvOut);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnBindToStorage
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnBindToStorage(IShellFolder2 * iface,
|
|
|
|
LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
FIXME("(%p)->(pidl=%p,%p,%s,%p) stub\n", This, pidl, pbcReserved, shdebugstr_guid(riid), ppvOut);
|
|
|
|
|
|
|
|
*ppvOut = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnCompareIDs
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnCompareIDs(IShellFolder2 * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
int nReturn;
|
|
|
|
|
|
|
|
TRACE("(%p)->(0x%08lx,pidl1=%p,pidl2=%p)\n", This, lParam, pidl1, pidl2);
|
|
|
|
nReturn = SHELL32_CompareIDs(_IShellFolder_(This), lParam, pidl1, pidl2);
|
|
|
|
TRACE("-- %i\n", nReturn);
|
|
|
|
return nReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnCreateViewObject
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnCreateViewObject(IShellFolder2 * iface, HWND hwndOwner, REFIID riid, LPVOID * ppvOut)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
LPSHELLVIEW pShellView;
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
TRACE("(%p)->(hwnd=%p,%s,%p)\n", This, hwndOwner, shdebugstr_guid(riid), ppvOut);
|
|
|
|
|
|
|
|
if (ppvOut) {
|
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IDropTarget)) {
|
|
|
|
WARN("IDropTarget not implemented\n");
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IContextMenu)) {
|
|
|
|
WARN("IContextMenu not implemented\n");
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IShellView)) {
|
|
|
|
pShellView = IShellView_Constructor((IShellFolder *) iface);
|
|
|
|
if (pShellView) {
|
|
|
|
hr = IShellView_QueryInterface(pShellView, riid, ppvOut);
|
|
|
|
IShellView_Release(pShellView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("--(%p)->(interface=%p)\n", This, ppvOut);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnGetAttributesOf
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnGetAttributesOf(IShellFolder2 * iface, UINT cidl, LPCITEMIDLIST * apidl, DWORD * rgfInOut)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
|
2005-05-10 10:28:11 +02:00
|
|
|
This, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2005-05-10 10:28:11 +02:00
|
|
|
if (!rgfInOut)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (cidl && !apidl)
|
|
|
|
return E_INVALIDARG;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2004-04-13 02:19:11 +02:00
|
|
|
if (*rgfInOut == 0)
|
|
|
|
*rgfInOut = ~0;
|
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
while(cidl > 0 && *apidl) {
|
|
|
|
pdump(*apidl);
|
|
|
|
SHELL32_GetItemAttributes(_IShellFolder_(This), *apidl, rgfInOut);
|
|
|
|
apidl++;
|
|
|
|
cidl--;
|
|
|
|
}
|
2005-05-10 10:28:11 +02:00
|
|
|
/* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
|
|
|
|
*rgfInOut &= ~SFGAO_VALIDATE;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("-- result=0x%08x\n", *rgfInOut);
|
2004-03-27 02:42:22 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnGetUIObjectOf
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* HWND hwndOwner, //[in ] Parent window for any output
|
|
|
|
* UINT cidl, //[in ] array size
|
|
|
|
* LPCITEMIDLIST* apidl, //[in ] simple pidl array
|
|
|
|
* REFIID riid, //[in ] Requested Interface
|
|
|
|
* UINT* prgfInOut, //[ ] reserved
|
|
|
|
* LPVOID* ppvObject) //[out] Resulting Interface
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI
|
|
|
|
ISF_ControlPanel_fnGetUIObjectOf(IShellFolder2 * iface,
|
|
|
|
HWND hwndOwner,
|
|
|
|
UINT cidl, LPCITEMIDLIST * apidl, REFIID riid, UINT * prgfInOut, LPVOID * ppvOut)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
IUnknown *pObj = NULL;
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p,%u,apidl=%p,%s,%p,%p)\n",
|
|
|
|
This, hwndOwner, cidl, apidl, shdebugstr_guid(riid), prgfInOut, ppvOut);
|
|
|
|
|
|
|
|
if (ppvOut) {
|
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IContextMenu) &&(cidl >= 1)) {
|
|
|
|
pObj = (LPUNKNOWN) ISvItemCm_Constructor((IShellFolder *) iface, This->pidlRoot, apidl, cidl);
|
|
|
|
hr = S_OK;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IDataObject) &&(cidl >= 1)) {
|
|
|
|
pObj = (LPUNKNOWN) IDataObject_Constructor(hwndOwner, This->pidlRoot, apidl, cidl);
|
|
|
|
hr = S_OK;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IExtractIconA) &&(cidl == 1)) {
|
|
|
|
pidl = ILCombine(This->pidlRoot, apidl[0]);
|
|
|
|
pObj = (LPUNKNOWN) IExtractIconA_Constructor(pidl);
|
|
|
|
SHFree(pidl);
|
|
|
|
hr = S_OK;
|
|
|
|
} else if (IsEqualIID(riid, &IID_IExtractIconW) &&(cidl == 1)) {
|
|
|
|
pidl = ILCombine(This->pidlRoot, apidl[0]);
|
|
|
|
pObj = (LPUNKNOWN) IExtractIconW_Constructor(pidl);
|
|
|
|
SHFree(pidl);
|
|
|
|
hr = S_OK;
|
|
|
|
} else if ((IsEqualIID(riid,&IID_IShellLinkW) || IsEqualIID(riid,&IID_IShellLinkA))
|
|
|
|
&& (cidl == 1)) {
|
|
|
|
pidl = ILCombine(This->pidlRoot, apidl[0]);
|
|
|
|
hr = IShellLink_ConstructFromFile(NULL, riid, pidl,(LPVOID*)&pObj);
|
|
|
|
SHFree(pidl);
|
|
|
|
} else {
|
|
|
|
hr = E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && !pObj)
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
*ppvOut = pObj;
|
|
|
|
}
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->hr=0x%08x\n", This, hr);
|
2004-03-27 02:42:22 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnGetDisplayNameOf
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnGetDisplayNameOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-01-16 21:31:10 +01:00
|
|
|
CHAR szPath[MAX_PATH];
|
|
|
|
WCHAR wszPath[MAX_PATH+1]; /* +1 for potential backslash */
|
2004-03-27 02:42:22 +01:00
|
|
|
PIDLCPanelStruct* pcpanel;
|
|
|
|
|
|
|
|
*szPath = '\0';
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(pidl=%p,0x%08x,%p)\n", This, pidl, dwFlags, strRet);
|
2004-03-27 02:42:22 +01:00
|
|
|
pdump(pidl);
|
|
|
|
|
|
|
|
if (!pidl || !strRet)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pcpanel = _ILGetCPanelPointer(pidl);
|
|
|
|
|
|
|
|
if (pcpanel) {
|
|
|
|
lstrcpyA(szPath, pcpanel->szName+pcpanel->offsDispName);
|
|
|
|
|
|
|
|
if (!(dwFlags & SHGDN_FORPARSING))
|
|
|
|
FIXME("retrieve display name from control panel app\n");
|
|
|
|
}
|
2006-11-07 00:37:42 +01:00
|
|
|
/* take names of special folders only if it's only this folder */
|
2004-03-27 02:42:22 +01:00
|
|
|
else if (_ILIsSpecialFolder(pidl)) {
|
|
|
|
BOOL bSimplePidl = _ILIsPidlSimple(pidl);
|
|
|
|
|
|
|
|
if (bSimplePidl) {
|
2006-01-16 21:31:10 +01:00
|
|
|
_ILSimpleGetTextW(pidl, wszPath, MAX_PATH); /* append my own path */
|
2004-03-27 02:42:22 +01:00
|
|
|
} else {
|
|
|
|
FIXME("special pidl\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { /* go deeper if needed */
|
|
|
|
int len = 0;
|
|
|
|
|
2006-01-16 21:31:10 +01:00
|
|
|
PathAddBackslashW(wszPath);
|
|
|
|
len = lstrlenW(wszPath);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2009-09-10 00:28:56 +02:00
|
|
|
if (FAILED(SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags | SHGDN_INFOLDER, wszPath + len, MAX_PATH + 1 - len)))
|
2004-03-27 02:42:22 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2006-01-16 21:31:10 +01:00
|
|
|
if (!WideCharToMultiByte(CP_ACP, 0, wszPath, -1, szPath, MAX_PATH, NULL, NULL))
|
|
|
|
wszPath[0] = '\0';
|
2004-03-27 02:42:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
strRet->uType = STRRET_CSTR;
|
|
|
|
lstrcpynA(strRet->u.cStr, szPath, MAX_PATH);
|
|
|
|
|
|
|
|
TRACE("--(%p)->(%s)\n", This, szPath);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* ISF_ControlPanel_fnSetNameOf
|
|
|
|
* Changes the name of a file object or subfolder, possibly changing its item
|
|
|
|
* identifier in the process.
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* HWND hwndOwner, //[in ] Owner window for output
|
|
|
|
* LPCITEMIDLIST pidl, //[in ] simple pidl of item to change
|
|
|
|
* LPCOLESTR lpszName, //[in ] the items new display name
|
|
|
|
* DWORD dwFlags, //[in ] SHGNO formatting flags
|
|
|
|
* LPITEMIDLIST* ppidlOut) //[out] simple pidl returned
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnSetNameOf(IShellFolder2 * iface, HWND hwndOwner, LPCITEMIDLIST pidl, /*simple pidl */
|
|
|
|
LPCOLESTR lpName, DWORD dwFlags, LPITEMIDLIST * pPidlOut)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("(%p)->(%p,pidl=%p,%s,%u,%p)\n", This, hwndOwner, pidl, debugstr_w(lpName), dwFlags, pPidlOut);
|
2004-03-27 02:42:22 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultSearchGUID(IShellFolder2 * iface, GUID * pguid)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnEnumSearches(IShellFolder2 * iface, IEnumExtraSearch ** ppenum)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumn(IShellFolder2 * iface, DWORD dwRes, ULONG * pSort, ULONG * pDisplay)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if (pSort) *pSort = 0;
|
|
|
|
if (pDisplay) *pDisplay = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnGetDefaultColumnState(IShellFolder2 * iface, UINT iColumn, DWORD * pcsFlags)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if (!pcsFlags || iColumn >= CONROLPANELSHELLVIEWCOLUMNS) return E_INVALIDARG;
|
|
|
|
*pcsFlags = ControlPanelSFHeader[iColumn].pcsFlags;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsEx(IShellFolder2 * iface, LPCITEMIDLIST pidl, const SHCOLUMNID * pscid, VARIANT * pv)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnGetDetailsOf(IShellFolder2 * iface, LPCITEMIDLIST pidl, UINT iColumn, SHELLDETAILS * psd)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2008-06-23 19:54:20 +02:00
|
|
|
PIDLCPanelStruct* pcpanel;
|
2004-03-27 02:42:22 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %i %p)\n", This, pidl, iColumn, psd);
|
|
|
|
|
|
|
|
if (!psd || iColumn >= CONROLPANELSHELLVIEWCOLUMNS)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!pidl) {
|
|
|
|
psd->fmt = ControlPanelSFHeader[iColumn].fmt;
|
|
|
|
psd->cxChar = ControlPanelSFHeader[iColumn].cxChar;
|
|
|
|
psd->str.uType = STRRET_CSTR;
|
|
|
|
LoadStringA(shell32_hInstance, ControlPanelSFHeader[iColumn].colnameid, psd->str.u.cStr, MAX_PATH);
|
|
|
|
return S_OK;
|
|
|
|
} else {
|
|
|
|
psd->str.u.cStr[0] = 0x00;
|
|
|
|
psd->str.uType = STRRET_CSTR;
|
|
|
|
switch(iColumn) {
|
|
|
|
case 0: /* name */
|
|
|
|
hr = IShellFolder_GetDisplayNameOf(iface, pidl, SHGDN_NORMAL | SHGDN_INFOLDER, &psd->str);
|
|
|
|
break;
|
|
|
|
case 1: /* comment */
|
2008-06-23 19:54:20 +02:00
|
|
|
pcpanel = _ILGetCPanelPointer(pidl);
|
|
|
|
|
|
|
|
if (pcpanel)
|
|
|
|
lstrcpyA(psd->str.u.cStr, pcpanel->szName+pcpanel->offsComment);
|
|
|
|
else
|
|
|
|
_ILGetFileType(pidl, psd->str.u.cStr, MAX_PATH);
|
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI ISF_ControlPanel_fnMapColumnToSCID(IShellFolder2 * iface, UINT column, SHCOLUMNID * pscid)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
FIXME("(%p)\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IShellFolder2Vtbl vt_ShellFolder2 =
|
2004-03-27 02:42:22 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
ISF_ControlPanel_fnQueryInterface,
|
|
|
|
ISF_ControlPanel_fnAddRef,
|
|
|
|
ISF_ControlPanel_fnRelease,
|
|
|
|
ISF_ControlPanel_fnParseDisplayName,
|
|
|
|
ISF_ControlPanel_fnEnumObjects,
|
|
|
|
ISF_ControlPanel_fnBindToObject,
|
|
|
|
ISF_ControlPanel_fnBindToStorage,
|
|
|
|
ISF_ControlPanel_fnCompareIDs,
|
|
|
|
ISF_ControlPanel_fnCreateViewObject,
|
|
|
|
ISF_ControlPanel_fnGetAttributesOf,
|
|
|
|
ISF_ControlPanel_fnGetUIObjectOf,
|
|
|
|
ISF_ControlPanel_fnGetDisplayNameOf,
|
|
|
|
ISF_ControlPanel_fnSetNameOf,
|
|
|
|
|
|
|
|
/* ShellFolder2 */
|
|
|
|
ISF_ControlPanel_fnGetDefaultSearchGUID,
|
|
|
|
ISF_ControlPanel_fnEnumSearches,
|
|
|
|
ISF_ControlPanel_fnGetDefaultColumn,
|
|
|
|
ISF_ControlPanel_fnGetDefaultColumnState,
|
|
|
|
ISF_ControlPanel_fnGetDetailsEx,
|
|
|
|
ISF_ControlPanel_fnGetDetailsOf,
|
|
|
|
ISF_ControlPanel_fnMapColumnToSCID
|
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* ICPanel_PersistFolder2_QueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ICPanel_PersistFolder2_QueryInterface(IPersistFolder2 * iface, REFIID iid, LPVOID * ppvObject)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface(_IUnknown_(This), iid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* ICPanel_PersistFolder2_AddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI ICPanel_PersistFolder2_AddRef(IPersistFolder2 * iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
return IUnknown_AddRef(_IUnknown_(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* ISFPersistFolder_Release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI ICPanel_PersistFolder2_Release(IPersistFolder2 * iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
return IUnknown_Release(_IUnknown_(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* ICPanel_PersistFolder2_GetClassID
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ICPanel_PersistFolder2_GetClassID(IPersistFolder2 * iface, CLSID * lpClassId)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if (!lpClassId)
|
|
|
|
return E_POINTER;
|
|
|
|
*lpClassId = CLSID_ControlPanel;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* ICPanel_PersistFolder2_Initialize
|
|
|
|
*
|
|
|
|
* NOTES: it makes no sense to change the pidl
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ICPanel_PersistFolder2_Initialize(IPersistFolder2 * iface, LPCITEMIDLIST pidl)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pidl);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IPersistFolder2_fnGetCurFolder
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI ICPanel_PersistFolder2_GetCurFolder(IPersistFolder2 * iface, LPITEMIDLIST * pidl)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IPersistFolder2(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pidl);
|
|
|
|
|
|
|
|
if (!pidl)
|
|
|
|
return E_POINTER;
|
|
|
|
*pidl = ILClone(This->pidlRoot);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IPersistFolder2Vtbl vt_PersistFolder2 =
|
2004-03-27 02:42:22 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
ICPanel_PersistFolder2_QueryInterface,
|
|
|
|
ICPanel_PersistFolder2_AddRef,
|
|
|
|
ICPanel_PersistFolder2_Release,
|
|
|
|
ICPanel_PersistFolder2_GetClassID,
|
|
|
|
ICPanel_PersistFolder2_Initialize,
|
|
|
|
ICPanel_PersistFolder2_GetCurFolder
|
|
|
|
};
|
|
|
|
|
2007-09-11 00:09:58 +02:00
|
|
|
HRESULT CPanel_GetIconLocationW(LPCITEMIDLIST pidl,
|
2005-03-19 18:08:52 +01:00
|
|
|
LPWSTR szIconFile, UINT cchMax, int* piIndex)
|
2004-03-27 02:42:22 +01:00
|
|
|
{
|
|
|
|
PIDLCPanelStruct* pcpanel = _ILGetCPanelPointer(pidl);
|
|
|
|
|
|
|
|
if (!pcpanel)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, szIconFile, cchMax);
|
|
|
|
*piIndex = pcpanel->iconIdx!=-1? pcpanel->iconIdx: 0;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IShellExecuteHookW Implementation
|
|
|
|
*/
|
|
|
|
|
2005-03-19 18:08:52 +01:00
|
|
|
static HRESULT WINAPI IShellExecuteHookW_fnQueryInterface(
|
|
|
|
IShellExecuteHookW* iface, REFIID riid, void** ppvObject)
|
2004-03-27 02:42:22 +01:00
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnAddRef(IShellExecuteHookW* iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
return IUnknown_AddRef(This->pUnkOuter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnRelease(IShellExecuteHookW* iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IUnknown_Release(This->pUnkOuter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW* iface, LPSHELLEXECUTEINFOW psei)
|
|
|
|
{
|
2005-02-09 14:25:13 +01:00
|
|
|
static const WCHAR wCplopen[] = {'c','p','l','o','p','e','n','\0'};
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
SHELLEXECUTEINFOW sei_tmp;
|
|
|
|
PIDLCPanelStruct* pcpanel;
|
|
|
|
WCHAR path[MAX_PATH];
|
2005-09-12 14:10:57 +02:00
|
|
|
WCHAR params[MAX_PATH];
|
2004-03-27 02:42:22 +01:00
|
|
|
BOOL ret;
|
|
|
|
int l;
|
|
|
|
|
|
|
|
TRACE("(%p)->execute(%p)\n", This, psei);
|
|
|
|
|
|
|
|
if (!psei)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
|
|
|
|
|
|
|
|
if (!pcpanel)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
path[0] = '\"';
|
2005-02-09 14:25:13 +01:00
|
|
|
/* Return value from MultiByteToWideChar includes terminating NUL, which
|
|
|
|
* compensates for the starting double quote we just put in */
|
2008-09-11 13:33:15 +02:00
|
|
|
l = MultiByteToWideChar(CP_ACP, 0, pcpanel->szName, -1, path+1, MAX_PATH-1);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
/* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
|
2005-02-09 14:25:13 +01:00
|
|
|
path[l++] = '"';
|
2005-09-12 14:10:57 +02:00
|
|
|
path[l] = '\0';
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2005-09-12 14:10:57 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pcpanel->szName+pcpanel->offsDispName, -1, params, MAX_PATH);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2008-03-17 22:36:59 +01:00
|
|
|
sei_tmp = *psei;
|
2004-03-27 02:42:22 +01:00
|
|
|
sei_tmp.lpFile = path;
|
2005-09-12 14:10:57 +02:00
|
|
|
sei_tmp.lpParameters = params;
|
2004-03-27 02:42:22 +01:00
|
|
|
sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
|
2005-02-09 14:25:13 +01:00
|
|
|
sei_tmp.lpVerb = wCplopen;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
ret = ShellExecuteExW(&sei_tmp);
|
|
|
|
if (ret)
|
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IShellExecuteHookWVtbl vt_ShellExecuteHookW =
|
2004-03-27 02:42:22 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
IShellExecuteHookW_fnQueryInterface,
|
|
|
|
IShellExecuteHookW_fnAddRef,
|
|
|
|
IShellExecuteHookW_fnRelease,
|
|
|
|
|
|
|
|
IShellExecuteHookW_fnExecute
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IShellExecuteHookA Implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
static HRESULT WINAPI IShellExecuteHookA_fnQueryInterface(IShellExecuteHookA* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
return IUnknown_QueryInterface(This->pUnkOuter, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnAddRef(IShellExecuteHookA* iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(count=%u)\n", This, This->ref);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
return IUnknown_AddRef(This->pUnkOuter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnRelease(IShellExecuteHookA* iface)
|
|
|
|
{
|
2005-07-27 13:10:52 +02:00
|
|
|
ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return IUnknown_Release(This->pUnkOuter);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA* iface, LPSHELLEXECUTEINFOA psei)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
ICPanelImpl *This = (ICPanelImpl *)iface;
|
2004-03-27 02:42:22 +01:00
|
|
|
|
|
|
|
SHELLEXECUTEINFOA sei_tmp;
|
|
|
|
PIDLCPanelStruct* pcpanel;
|
|
|
|
char path[MAX_PATH];
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("(%p)->execute(%p)\n", This, psei);
|
|
|
|
|
|
|
|
if (!psei)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
pcpanel = _ILGetCPanelPointer(ILFindLastID(psei->lpIDList));
|
|
|
|
|
|
|
|
if (!pcpanel)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
path[0] = '\"';
|
|
|
|
lstrcpyA(path+1, pcpanel->szName);
|
|
|
|
|
|
|
|
/* pass applet name to Control_RunDLL to distinguish between applets in one .cpl file */
|
|
|
|
lstrcatA(path, "\" ");
|
|
|
|
lstrcatA(path, pcpanel->szName+pcpanel->offsDispName);
|
|
|
|
|
2008-03-17 22:36:59 +01:00
|
|
|
sei_tmp = *psei;
|
2004-03-27 02:42:22 +01:00
|
|
|
sei_tmp.lpFile = path;
|
|
|
|
sei_tmp.fMask &= ~SEE_MASK_INVOKEIDLIST;
|
|
|
|
|
|
|
|
ret = ShellExecuteExA(&sei_tmp);
|
|
|
|
if (ret)
|
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IShellExecuteHookAVtbl vt_ShellExecuteHookA =
|
2004-03-27 02:42:22 +01:00
|
|
|
{
|
|
|
|
IShellExecuteHookA_fnQueryInterface,
|
|
|
|
IShellExecuteHookA_fnAddRef,
|
|
|
|
IShellExecuteHookA_fnRelease,
|
|
|
|
IShellExecuteHookA_fnExecute
|
|
|
|
};
|