shell32: Finish the COM cleanup in cpanelfolder.c.

This commit is contained in:
Michael Stefaniuc 2011-05-31 10:20:27 +02:00 committed by Alexandre Julliard
parent 567bb185b5
commit a81f954b0d

View File

@ -60,10 +60,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
typedef struct { typedef struct {
IShellFolder2 IShellFolder2_iface; IShellFolder2 IShellFolder2_iface;
IPersistFolder2 IPersistFolder2_iface;
IShellExecuteHookW IShellExecuteHookW_iface;
IShellExecuteHookA IShellExecuteHookA_iface;
LONG ref; LONG ref;
const IPersistFolder2Vtbl *lpVtblPersistFolder2;
const IShellExecuteHookWVtbl *lpVtblShellExecuteHookW;
const IShellExecuteHookAVtbl *lpVtblShellExecuteHookA;
IUnknown *pUnkOuter; /* used for aggregation */ IUnknown *pUnkOuter; /* used for aggregation */
@ -84,29 +84,20 @@ static inline ICPanelImpl *impl_from_IShellFolder2(IShellFolder2 *iface)
static inline ICPanelImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface) static inline ICPanelImpl *impl_from_IPersistFolder2(IPersistFolder2 *iface)
{ {
return (ICPanelImpl *)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblPersistFolder2)); return CONTAINING_RECORD(iface, ICPanelImpl, IPersistFolder2_iface);
} }
static inline ICPanelImpl *impl_from_IShellExecuteHookW(IShellExecuteHookW *iface) static inline ICPanelImpl *impl_from_IShellExecuteHookW(IShellExecuteHookW *iface)
{ {
return (ICPanelImpl *)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblShellExecuteHookW)); return CONTAINING_RECORD(iface, ICPanelImpl, IShellExecuteHookW_iface);
} }
static inline ICPanelImpl *impl_from_IShellExecuteHookA(IShellExecuteHookA *iface) static inline ICPanelImpl *impl_from_IShellExecuteHookA(IShellExecuteHookA *iface)
{ {
return (ICPanelImpl *)((char*)iface - FIELD_OFFSET(ICPanelImpl, lpVtblShellExecuteHookA)); return CONTAINING_RECORD(iface, ICPanelImpl, IShellExecuteHookA_iface);
} }
/*
converts This to an interface pointer
*/
#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)
/*********************************************************************** /***********************************************************************
* IShellFolder [ControlPanel] implementation * IShellFolder [ControlPanel] implementation
*/ */
@ -138,9 +129,9 @@ HRESULT WINAPI IControlPanel_Constructor(IUnknown* pUnkOuter, REFIID riid, LPVOI
sf->ref = 0; sf->ref = 0;
sf->IShellFolder2_iface.lpVtbl = &vt_ShellFolder2; sf->IShellFolder2_iface.lpVtbl = &vt_ShellFolder2;
sf->lpVtblPersistFolder2 = &vt_PersistFolder2; sf->IPersistFolder2_iface.lpVtbl = &vt_PersistFolder2;
sf->lpVtblShellExecuteHookW = &vt_ShellExecuteHookW; sf->IShellExecuteHookW_iface.lpVtbl = &vt_ShellExecuteHookW;
sf->lpVtblShellExecuteHookA = &vt_ShellExecuteHookA; sf->IShellExecuteHookA_iface.lpVtbl = &vt_ShellExecuteHookA;
sf->pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */ sf->pidlRoot = _ILCreateControlPanel(); /* my qualified pidl */
sf->pUnkOuter = pUnkOuter ? pUnkOuter : (IUnknown *)&sf->IShellFolder2_iface; sf->pUnkOuter = pUnkOuter ? pUnkOuter : (IUnknown *)&sf->IShellFolder2_iface;
@ -172,11 +163,11 @@ static HRESULT WINAPI ISF_ControlPanel_fnQueryInterface(IShellFolder2 *iface, RE
*ppvObject = This; *ppvObject = This;
else if (IsEqualIID(riid, &IID_IPersist) || else if (IsEqualIID(riid, &IID_IPersist) ||
IsEqualIID(riid, &IID_IPersistFolder) || IsEqualIID(riid, &IID_IPersistFolder2)) IsEqualIID(riid, &IID_IPersistFolder) || IsEqualIID(riid, &IID_IPersistFolder2))
*ppvObject = _IPersistFolder2_(This); *ppvObject = &This->IPersistFolder2_iface;
else if (IsEqualIID(riid, &IID_IShellExecuteHookW)) else if (IsEqualIID(riid, &IID_IShellExecuteHookW))
*ppvObject = _IShellExecuteHookW_(This); *ppvObject = &This->IShellExecuteHookW_iface;
else if (IsEqualIID(riid, &IID_IShellExecuteHookA)) else if (IsEqualIID(riid, &IID_IShellExecuteHookA))
*ppvObject = _IShellExecuteHookA_(This); *ppvObject = &This->IShellExecuteHookA_iface;
if (*ppvObject) { if (*ppvObject) {
IUnknown_AddRef((IUnknown *)(*ppvObject)); IUnknown_AddRef((IUnknown *)(*ppvObject));
@ -973,10 +964,11 @@ static ULONG STDMETHODCALLTYPE IShellExecuteHookW_fnRelease(IShellExecuteHookW*
return IUnknown_Release(This->pUnkOuter); return IUnknown_Release(This->pUnkOuter);
} }
static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW* iface, LPSHELLEXECUTEINFOW psei) static HRESULT WINAPI IShellExecuteHookW_fnExecute(IShellExecuteHookW *iface,
LPSHELLEXECUTEINFOW psei)
{ {
ICPanelImpl *This = impl_from_IShellExecuteHookW(iface);
static const WCHAR wCplopen[] = {'c','p','l','o','p','e','n','\0'}; static const WCHAR wCplopen[] = {'c','p','l','o','p','e','n','\0'};
ICPanelImpl *This = (ICPanelImpl *)iface;
SHELLEXECUTEINFOW sei_tmp; SHELLEXECUTEINFOW sei_tmp;
PIDLCPanelStruct* pcpanel; PIDLCPanelStruct* pcpanel;
@ -1061,9 +1053,10 @@ static ULONG STDMETHODCALLTYPE IShellExecuteHookA_fnRelease(IShellExecuteHookA*
return IUnknown_Release(This->pUnkOuter); return IUnknown_Release(This->pUnkOuter);
} }
static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA* iface, LPSHELLEXECUTEINFOA psei) static HRESULT WINAPI IShellExecuteHookA_fnExecute(IShellExecuteHookA *iface,
LPSHELLEXECUTEINFOA psei)
{ {
ICPanelImpl *This = (ICPanelImpl *)iface; ICPanelImpl *This = impl_from_IShellExecuteHookA(iface);
SHELLEXECUTEINFOA sei_tmp; SHELLEXECUTEINFOA sei_tmp;
PIDLCPanelStruct* pcpanel; PIDLCPanelStruct* pcpanel;