wine-wine/dlls/wshom.ocx/shell.c

409 lines
12 KiB
C
Raw Normal View History

/*
* Copyright 2011 Jacek Caban for CodeWeavers
*
* 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
* version 2.1 of the License, or (at your option) any later version.
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wshom_private.h"
#include "wshom.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(wshom);
const char *debugstr_variant(const VARIANT *v)
{
if(!v)
return "(null)";
switch(V_VT(v)) {
case VT_EMPTY:
return "{VT_EMPTY}";
case VT_NULL:
return "{VT_NULL}";
case VT_I4:
return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
case VT_R8:
return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
case VT_BSTR:
return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
case VT_DISPATCH:
return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
case VT_BOOL:
return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
case VT_UNKNOWN:
return wine_dbg_sprintf("{VT_UNKNOWN: %p}", V_UNKNOWN(v));
case VT_UINT:
return wine_dbg_sprintf("{VT_UINT: %u}", V_UINT(v));
case VT_BSTR|VT_BYREF:
return wine_dbg_sprintf("{VT_BSTR|VT_BYREF: ptr %p, data %s}",
V_BSTRREF(v), debugstr_w(V_BSTRREF(v) ? *V_BSTRREF(v) : NULL));
default:
return wine_dbg_sprintf("{vt %d}", V_VT(v));
}
}
static IWshShell3 WshShell3;
typedef struct
{
IWshCollection IWshCollection_iface;
LONG ref;
} WshCollection;
static inline WshCollection *impl_from_IWshCollection( IWshCollection *iface )
{
return CONTAINING_RECORD(iface, WshCollection, IWshCollection_iface);
}
static HRESULT WINAPI WshCollection_QueryInterface(IWshCollection *iface, REFIID riid, void **ppv)
{
WshCollection *This = impl_from_IWshCollection(iface);
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IDispatch) ||
IsEqualGUID(riid, &IID_IWshCollection))
{
*ppv = iface;
}else {
FIXME("Unknown iface %s\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI WshCollection_AddRef(IWshCollection *iface)
{
WshCollection *This = impl_from_IWshCollection(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref = %d\n", This, ref);
return ref;
}
static ULONG WINAPI WshCollection_Release(IWshCollection *iface)
{
WshCollection *This = impl_from_IWshCollection(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref = %d\n", This, ref);
if (!ref)
HeapFree(GetProcessHeap(), 0, This);
return ref;
}
static HRESULT WINAPI WshCollection_GetTypeInfoCount(IWshCollection *iface, UINT *pctinfo)
{
WshCollection *This = impl_from_IWshCollection(iface);
TRACE("(%p)->(%p)\n", This, pctinfo);
*pctinfo = 1;
return S_OK;
}
static HRESULT WINAPI WshCollection_GetTypeInfo(IWshCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
WshCollection *This = impl_from_IWshCollection(iface);
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
return get_typeinfo(IWshCollection_tid, ppTInfo);
}
static HRESULT WINAPI WshCollection_GetIDsOfNames(IWshCollection *iface, REFIID riid, LPOLESTR *rgszNames,
UINT cNames, LCID lcid, DISPID *rgDispId)
{
WshCollection *This = impl_from_IWshCollection(iface);
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
hr = get_typeinfo(IWshCollection_tid, &typeinfo);
if(SUCCEEDED(hr))
{
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI WshCollection_Invoke(IWshCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
WshCollection *This = impl_from_IWshCollection(iface);
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
hr = get_typeinfo(IWshCollection_tid, &typeinfo);
if(SUCCEEDED(hr))
{
hr = ITypeInfo_Invoke(typeinfo, &This->IWshCollection_iface, dispIdMember, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI WshCollection_Item(IWshCollection *iface, VARIANT *index, VARIANT *value)
{
WshCollection *This = impl_from_IWshCollection(iface);
FIXME("(%p)->(%s %p): stub\n", This, debugstr_variant(index), value);
return E_NOTIMPL;
}
static HRESULT WINAPI WshCollection_Count(IWshCollection *iface, LONG *count)
{
WshCollection *This = impl_from_IWshCollection(iface);
FIXME("(%p)->(%p): stub\n", This, count);
return E_NOTIMPL;
}
static HRESULT WINAPI WshCollection_get_length(IWshCollection *iface, LONG *count)
{
WshCollection *This = impl_from_IWshCollection(iface);
FIXME("(%p)->(%p): stub\n", This, count);
return E_NOTIMPL;
}
static HRESULT WINAPI WshCollection__NewEnum(IWshCollection *iface, IUnknown *Enum)
{
WshCollection *This = impl_from_IWshCollection(iface);
FIXME("(%p)->(%p): stub\n", This, Enum);
return E_NOTIMPL;
}
static const IWshCollectionVtbl WshCollectionVtbl = {
WshCollection_QueryInterface,
WshCollection_AddRef,
WshCollection_Release,
WshCollection_GetTypeInfoCount,
WshCollection_GetTypeInfo,
WshCollection_GetIDsOfNames,
WshCollection_Invoke,
WshCollection_Item,
WshCollection_Count,
WshCollection_get_length,
WshCollection__NewEnum
};
static HRESULT WshCollection_Create(IWshCollection **collection)
{
WshCollection *This;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IWshCollection_iface.lpVtbl = &WshCollectionVtbl;
This->ref = 1;
*collection = &This->IWshCollection_iface;
return S_OK;
}
static HRESULT WINAPI WshShell3_QueryInterface(IWshShell3 *iface, REFIID riid, void **ppv)
{
TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
if(IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IDispatch) ||
IsEqualGUID(riid, &IID_IWshShell3))
{
*ppv = iface;
}else {
FIXME("Unknown iface %s\n", debugstr_guid(riid));
*ppv = NULL;
return E_NOINTERFACE;
}
IWshShell3_AddRef(iface);
return S_OK;
}
static ULONG WINAPI WshShell3_AddRef(IWshShell3 *iface)
{
TRACE("()\n");
return 2;
}
static ULONG WINAPI WshShell3_Release(IWshShell3 *iface)
{
TRACE("()\n");
return 2;
}
static HRESULT WINAPI WshShell3_GetTypeInfoCount(IWshShell3 *iface, UINT *pctinfo)
{
TRACE("(%p)\n", pctinfo);
*pctinfo = 1;
return S_OK;
}
static HRESULT WINAPI WshShell3_GetTypeInfo(IWshShell3 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
TRACE("(%u %u %p)\n", iTInfo, lcid, ppTInfo);
return get_typeinfo(IWshShell3_tid, ppTInfo);
}
static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LPOLESTR *rgszNames,
UINT cNames, LCID lcid, DISPID *rgDispId)
{
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("(%s %p %u %u %p)\n", debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
hr = get_typeinfo(IWshShell3_tid, &typeinfo);
if(SUCCEEDED(hr))
{
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI WshShell3_Invoke(IWshShell3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
ITypeInfo *typeinfo;
HRESULT hr;
TRACE("(%d %s %d %d %p %p %p %p)\n", dispIdMember, debugstr_guid(riid),
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
hr = get_typeinfo(IWshShell3_tid, &typeinfo);
if(SUCCEEDED(hr))
{
hr = ITypeInfo_Invoke(typeinfo, &WshShell3, dispIdMember, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
ITypeInfo_Release(typeinfo);
}
return hr;
}
static HRESULT WINAPI WshShell3_get_SpecialFolders(IWshShell3 *iface, IWshCollection **folders)
{
TRACE("(%p)\n", folders);
return WshCollection_Create(folders);
}
static HRESULT WINAPI WshShell3_get_Environment(IWshShell3 *iface, VARIANT *Type, IWshEnvironment **out_Env)
{
2011-12-30 10:40:13 +00:00
FIXME("(%p %p): stub\n", Type, out_Env);
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR Command, VARIANT *WindowStyle, VARIANT *WaitOnReturn, int *out_ExitCode)
{
FIXME("(%s %s %p): stub\n", debugstr_variant(WindowStyle), debugstr_variant(WaitOnReturn), out_ExitCode);
2011-12-30 10:40:13 +00:00
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_Popup(IWshShell3 *iface, BSTR Text, VARIANT* SecondsToWait, VARIANT *Title, VARIANT *Type, int *button)
{
FIXME("(%s %s %s %s %p): stub\n", debugstr_w(Text), debugstr_variant(SecondsToWait),
debugstr_variant(Title), debugstr_variant(Type), button);
2011-12-30 10:40:13 +00:00
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_CreateShortcut(IWshShell3 *iface, BSTR PathLink, IDispatch** out_Shortcut)
{
FIXME("(%s %p): stub\n", debugstr_w(PathLink), out_Shortcut);
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_ExpandEnvironmentStrings(IWshShell3 *iface, BSTR Src, BSTR* out_Dst)
{
FIXME("(%s %p): stub\n", debugstr_w(Src), out_Dst);
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_RegRead(IWshShell3 *iface, BSTR Name, VARIANT* out_Value)
{
FIXME("(%s %p): stub\n", debugstr_w(Name), out_Value);
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_RegWrite(IWshShell3 *iface, BSTR Name, VARIANT *Value, VARIANT *Type)
{
FIXME("(%s %s %s): stub\n", debugstr_w(Name), debugstr_variant(Value), debugstr_variant(Type));
2011-12-30 10:40:13 +00:00
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_RegDelete(IWshShell3 *iface, BSTR Name)
{
FIXME("(%s): stub\n", debugstr_w(Name));
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_LogEvent(IWshShell3 *iface, VARIANT *Type, BSTR Message, BSTR Target, VARIANT_BOOL *out_Success)
{
FIXME("(%s %s %s %p): stub\n", debugstr_variant(Type), debugstr_w(Message), debugstr_w(Target), out_Success);
2011-12-30 10:40:13 +00:00
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_AppActivate(IWshShell3 *iface, VARIANT *App, VARIANT *Wait, VARIANT_BOOL *out_Success)
{
FIXME("(%s %s %p): stub\n", debugstr_variant(App), debugstr_variant(Wait), out_Success);
2011-12-30 10:40:13 +00:00
return E_NOTIMPL;
}
static HRESULT WINAPI WshShell3_SendKeys(IWshShell3 *iface, BSTR Keys, VARIANT *Wait)
{
FIXME("(%s %p): stub\n", debugstr_w(Keys), Wait);
return E_NOTIMPL;
}
static const IWshShell3Vtbl WshShell3Vtbl = {
WshShell3_QueryInterface,
WshShell3_AddRef,
WshShell3_Release,
WshShell3_GetTypeInfoCount,
WshShell3_GetTypeInfo,
WshShell3_GetIDsOfNames,
WshShell3_Invoke,
WshShell3_get_SpecialFolders,
WshShell3_get_Environment,
2011-12-30 10:40:13 +00:00
WshShell3_Run,
WshShell3_Popup,
WshShell3_CreateShortcut,
WshShell3_ExpandEnvironmentStrings,
WshShell3_RegRead,
WshShell3_RegWrite,
WshShell3_RegDelete,
WshShell3_LogEvent,
WshShell3_AppActivate,
WshShell3_SendKeys
};
static IWshShell3 WshShell3 = { &WshShell3Vtbl };
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
{
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
return IWshShell3_QueryInterface(&WshShell3, riid, ppv);
}