2011-09-20 09:55:34 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2011-09-20 09:55:44 +00:00
|
|
|
#include "wshom.h"
|
2011-09-20 09:55:34 +00:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wshom);
|
|
|
|
|
2011-12-29 09:16:22 +00:00
|
|
|
static IWshShell3 WshShell3;
|
|
|
|
|
2011-12-30 13:13:40 +00:00
|
|
|
typedef struct
|
2011-09-20 09:55:44 +00:00
|
|
|
{
|
2011-12-30 13:13:40 +00:00
|
|
|
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))
|
|
|
|
{
|
2011-09-20 09:55:44 +00:00
|
|
|
*ppv = iface;
|
|
|
|
}else {
|
|
|
|
FIXME("Unknown iface %s\n", debugstr_guid(riid));
|
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-30 13:13:40 +00:00
|
|
|
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);
|
|
|
|
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)->(%p %p): stub\n", This, 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;
|
|
|
|
}
|
|
|
|
|
2011-09-20 09:55:44 +00:00
|
|
|
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)
|
|
|
|
{
|
2011-12-29 09:16:22 +00:00
|
|
|
TRACE("(%u %u %p)\n", iTInfo, lcid, ppTInfo);
|
|
|
|
return get_typeinfo(IWshShell3_tid, ppTInfo);
|
2011-09-20 09:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WshShell3_GetIDsOfNames(IWshShell3 *iface, REFIID riid, LPOLESTR *rgszNames,
|
|
|
|
UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2011-12-29 09:16:22 +00:00
|
|
|
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;
|
2011-09-20 09:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WshShell3_Invoke(IWshShell3 *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2011-12-29 09:16:22 +00:00
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%d %s %d %d %p %p %p %p)\n", dispIdMember, debugstr_guid(riid),
|
2011-09-20 09:55:44 +00:00
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2011-12-29 09:16:22 +00:00
|
|
|
|
|
|
|
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;
|
2011-09-20 09:55:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-30 13:13:40 +00:00
|
|
|
static HRESULT WINAPI WshShell3_get_SpecialFolders(IWshShell3 *iface, IWshCollection **folders)
|
2011-09-20 09:55:44 +00:00
|
|
|
{
|
2011-12-30 13:13:40 +00:00
|
|
|
TRACE("(%p)\n", folders);
|
|
|
|
return WshCollection_Create(folders);
|
2011-09-20 09:55:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2011-09-20 09:55:44 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WshShell3_Run(IWshShell3 *iface, BSTR Command, VARIANT *WindowStyle, VARIANT *WaitOnReturn, int *out_ExitCode)
|
|
|
|
{
|
2011-12-30 10:40:13 +00:00
|
|
|
FIXME("(%p %p %p): stub\n", WindowStyle, WaitOnReturn, out_ExitCode);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WshShell3_Popup(IWshShell3 *iface, BSTR Text, VARIANT* SecondsToWait, VARIANT *Title, VARIANT *Type, int *button)
|
|
|
|
{
|
|
|
|
FIXME("(%s %p %p %p %p): stub\n", debugstr_w(Text), SecondsToWait, Title, Type, button);
|
|
|
|
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 %p %p): stub\n", debugstr_w(Name), Value, Type);
|
|
|
|
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("(%p %s %s %p): stub\n", Type, debugstr_w(Message), debugstr_w(Target), out_Success);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WshShell3_AppActivate(IWshShell3 *iface, VARIANT *App, VARIANT *Wait, VARIANT_BOOL *out_Success)
|
|
|
|
{
|
|
|
|
FIXME("(%p %p %p): stub\n", App, Wait, out_Success);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI WshShell3_SendKeys(IWshShell3 *iface, BSTR Keys, VARIANT *Wait)
|
|
|
|
{
|
|
|
|
FIXME("(%s %p): stub\n", debugstr_w(Keys), Wait);
|
2011-09-20 09:55:44 +00:00
|
|
|
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
|
2011-09-20 09:55:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static IWshShell3 WshShell3 = { &WshShell3Vtbl };
|
|
|
|
|
2011-09-20 09:55:34 +00:00
|
|
|
HRESULT WINAPI WshShellFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
|
|
|
|
{
|
2011-09-20 09:55:44 +00:00
|
|
|
TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
return IWshShell3_QueryInterface(&WshShell3, riid, ppv);
|
2011-09-20 09:55:34 +00:00
|
|
|
}
|