2007-05-01 03:53:43 +02:00
|
|
|
/*
|
|
|
|
* Implementation of OLE Automation for Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2007 Misha Koshelev
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winuser.h"
|
2007-05-10 22:40:28 +02:00
|
|
|
#include "winreg.h"
|
2007-05-01 03:53:43 +02:00
|
|
|
#include "msidefs.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "activscp.h"
|
|
|
|
#include "oleauto.h"
|
2007-12-02 08:35:33 +01:00
|
|
|
#include "shlwapi.h"
|
2007-05-01 03:53:43 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "msiserver.h"
|
2007-05-01 03:53:49 +02:00
|
|
|
#include "msiserver_dispids.h"
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2008-03-20 08:07:37 +01:00
|
|
|
#define REG_INDEX_CLASSES_ROOT 0
|
|
|
|
#define REG_INDEX_DYN_DATA 6
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
typedef struct AutomationObject AutomationObject;
|
|
|
|
|
|
|
|
/* function that is called from AutomationObject::Invoke, specific to this type of object */
|
|
|
|
typedef HRESULT (*auto_invoke_func)(AutomationObject* This,
|
|
|
|
DISPID dispIdMember, REFIID riid, LCID lcid, WORD flags, DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* result, EXCEPINFO* ei, UINT* arg_err);
|
|
|
|
/* function that is called from AutomationObject::Release when the object is being freed
|
|
|
|
to free any private data structures (or NULL) */
|
|
|
|
typedef void (*auto_free_func)(AutomationObject* This);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
REFIID riid;
|
|
|
|
auto_invoke_func fn_invoke;
|
|
|
|
auto_free_func fn_free;
|
|
|
|
} tid_id_t;
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT database_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
|
|
|
|
static HRESULT installer_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
|
|
|
|
static HRESULT record_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
|
|
|
|
static HRESULT session_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
|
|
|
|
static HRESULT list_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
|
|
|
|
static void list_free(AutomationObject*);
|
|
|
|
static HRESULT summaryinfo_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
|
|
|
|
static HRESULT view_invoke(AutomationObject*,DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
|
|
|
|
|
|
|
|
static tid_id_t tid_ids[] = {
|
|
|
|
{ &DIID_Database, database_invoke },
|
|
|
|
{ &DIID_Installer, installer_invoke },
|
|
|
|
{ &DIID_Record, record_invoke },
|
|
|
|
{ &DIID_Session, session_invoke },
|
|
|
|
{ &DIID_StringList, list_invoke, list_free },
|
|
|
|
{ &DIID_SummaryInfo, summaryinfo_invoke },
|
|
|
|
{ &DIID_View, view_invoke }
|
2012-11-14 05:45:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static ITypeLib *typelib;
|
|
|
|
static ITypeInfo *typeinfos[LAST_tid];
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static const IID *get_riid_from_tid(tid_t tid)
|
|
|
|
{
|
|
|
|
return tid_ids[tid].riid;
|
|
|
|
}
|
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!typelib)
|
|
|
|
{
|
|
|
|
ITypeLib *lib;
|
|
|
|
|
|
|
|
hr = LoadRegTypeLib(&LIBID_WindowsInstaller, 1, 0, LOCALE_NEUTRAL, &lib);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
static const WCHAR msiserverW[] = {'m','s','i','s','e','r','v','e','r','.','t','l','b',0};
|
|
|
|
hr = LoadTypeLib(msiserverW, &lib);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ERR("Could not load msiserver.tlb\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void**)&typelib, lib, NULL))
|
|
|
|
ITypeLib_Release(lib);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!typeinfos[tid])
|
|
|
|
{
|
|
|
|
ITypeInfo *ti;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = ITypeLib_GetTypeInfoOfGuid(typelib, get_riid_from_tid(tid), &ti);
|
2012-11-14 05:45:02 +01:00
|
|
|
if (FAILED(hr)) {
|
2012-11-14 06:26:14 +01:00
|
|
|
ERR("Could not load ITypeInfo for %s\n", debugstr_guid(get_riid_from_tid(tid)));
|
2012-11-14 05:45:02 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
|
|
|
|
ITypeInfo_Release(ti);
|
|
|
|
}
|
|
|
|
|
|
|
|
*typeinfo = typeinfos[tid];
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_typelib(void)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
|
|
|
|
if (typeinfos[i])
|
|
|
|
ITypeInfo_Release(typeinfos[i]);
|
|
|
|
|
|
|
|
if (typelib)
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
}
|
|
|
|
|
2007-05-01 03:53:43 +02:00
|
|
|
/*
|
|
|
|
* AutomationObject - "base" class for all automation objects. For each interface, we implement Invoke function
|
2012-01-17 00:12:30 +01:00
|
|
|
* called from AutomationObject::Invoke.
|
2007-05-01 03:53:43 +02:00
|
|
|
*/
|
2011-08-31 16:15:12 +02:00
|
|
|
struct AutomationObject {
|
2012-01-14 12:06:17 +01:00
|
|
|
IDispatch IDispatch_iface;
|
|
|
|
IProvideMultipleClassInfo IProvideMultipleClassInfo_iface;
|
2007-05-01 03:53:43 +02:00
|
|
|
LONG ref;
|
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
/* type id for this class */
|
|
|
|
tid_t tid;
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
/* The MSI handle of the current object */
|
|
|
|
MSIHANDLE msiHandle;
|
|
|
|
};
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
typedef struct {
|
|
|
|
AutomationObject autoobj;
|
|
|
|
int count;
|
|
|
|
VARIANT *data;
|
|
|
|
} ListObject;
|
2012-01-14 12:06:17 +01:00
|
|
|
|
2012-01-17 00:12:30 +01:00
|
|
|
static HRESULT create_database(MSIHANDLE, IDispatch**);
|
2012-01-14 23:32:01 +01:00
|
|
|
static HRESULT create_list_enumerator(ListObject*, void**);
|
2012-01-17 00:12:30 +01:00
|
|
|
static HRESULT create_summaryinfo(MSIHANDLE, IDispatch**);
|
|
|
|
static HRESULT create_view(MSIHANDLE, IDispatch**);
|
2007-05-18 18:23:19 +02:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
/* ListEnumerator - IEnumVARIANT implementation for MSI automation lists */
|
2011-08-31 16:15:12 +02:00
|
|
|
typedef struct {
|
2011-09-02 10:24:01 +02:00
|
|
|
IEnumVARIANT IEnumVARIANT_iface;
|
2007-05-18 18:23:19 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
/* Current position and pointer to AutomationObject that stores actual data */
|
2012-01-14 23:32:01 +01:00
|
|
|
ULONG pos;
|
|
|
|
ListObject *list;
|
2011-08-31 16:15:12 +02:00
|
|
|
} ListEnumerator;
|
2007-05-18 18:23:19 +02:00
|
|
|
|
2007-05-08 00:49:45 +02:00
|
|
|
typedef struct {
|
2012-01-14 14:34:13 +01:00
|
|
|
AutomationObject autoobj;
|
|
|
|
IDispatch *installer;
|
|
|
|
} SessionObject;
|
2007-05-08 00:49:45 +02:00
|
|
|
|
2012-01-14 14:43:31 +01:00
|
|
|
static inline AutomationObject *impl_from_IProvideMultipleClassInfo( IProvideMultipleClassInfo *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AutomationObject, IProvideMultipleClassInfo_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline AutomationObject *impl_from_IDispatch( IDispatch *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, AutomationObject, IDispatch_iface);
|
|
|
|
}
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
/* AutomationObject methods */
|
2007-05-01 03:53:43 +02:00
|
|
|
static HRESULT WINAPI AutomationObject_QueryInterface(IDispatch* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IDispatch(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
if (ppvObject == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IDispatch) ||
|
2012-11-14 06:26:14 +01:00
|
|
|
IsEqualGUID(riid, get_riid_from_tid(This->tid)))
|
2012-01-14 12:06:17 +01:00
|
|
|
*ppvObject = &This->IDispatch_iface;
|
2007-05-01 03:53:43 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_IProvideClassInfo) ||
|
|
|
|
IsEqualGUID(riid, &IID_IProvideClassInfo2) ||
|
|
|
|
IsEqualGUID(riid, &IID_IProvideMultipleClassInfo))
|
2012-01-14 12:06:17 +01:00
|
|
|
*ppvObject = &This->IProvideMultipleClassInfo_iface;
|
2007-05-01 03:53:43 +02:00
|
|
|
else
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
TRACE("() : asking for unsupported interface %s\n", debugstr_guid(riid));
|
2007-05-17 18:35:53 +02:00
|
|
|
return E_NOINTERFACE;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
IDispatch_AddRef(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AutomationObject_AddRef(IDispatch* iface)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IDispatch(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)\n", iface, This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AutomationObject_Release(IDispatch* iface)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IDispatch(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)\n", iface, This);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
2012-11-14 06:26:14 +01:00
|
|
|
if (tid_ids[This->tid].fn_free) tid_ids[This->tid].fn_free(This);
|
2007-05-17 18:35:53 +02:00
|
|
|
MsiCloseHandle(This->msiHandle);
|
2010-05-20 12:01:50 +02:00
|
|
|
msi_free(This);
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AutomationObject_GetTypeInfoCount(
|
|
|
|
IDispatch* iface,
|
|
|
|
UINT* pctinfo)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IDispatch(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", iface, This, pctinfo);
|
|
|
|
*pctinfo = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AutomationObject_GetTypeInfo(
|
|
|
|
IDispatch* iface,
|
|
|
|
UINT iTInfo,
|
|
|
|
LCID lcid,
|
|
|
|
ITypeInfo** ppTInfo)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IDispatch(iface);
|
2012-11-14 05:45:02 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2007-05-01 03:53:43 +02:00
|
|
|
TRACE("(%p/%p)->(%d,%d,%p)\n", iface, This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
hr = get_typeinfo(This->tid, ppTInfo);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
ITypeInfo_AddRef(*ppTInfo);
|
|
|
|
return hr;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI AutomationObject_GetIDsOfNames(
|
|
|
|
IDispatch* iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IDispatch(iface);
|
2012-11-14 05:45:02 +01:00
|
|
|
ITypeInfo *ti;
|
2007-05-08 00:51:07 +02:00
|
|
|
HRESULT hr;
|
2012-11-14 05:45:02 +01:00
|
|
|
|
2016-07-22 12:00:09 +02:00
|
|
|
TRACE("(%p/%p)->(%s, %p, %d, %d, %p)\n", iface, This,
|
|
|
|
debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
if (!IsEqualGUID(riid, &IID_NULL)) return E_INVALIDARG;
|
2012-11-14 05:45:02 +01:00
|
|
|
|
|
|
|
hr = get_typeinfo(This->tid, &ti);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(ti, rgszNames, cNames, rgDispId);
|
2007-05-08 00:51:07 +02:00
|
|
|
if (hr == DISP_E_UNKNOWNNAME)
|
|
|
|
{
|
2008-10-20 23:06:16 +02:00
|
|
|
UINT idx;
|
2007-05-08 00:51:07 +02:00
|
|
|
for (idx=0; idx<cNames; idx++)
|
|
|
|
{
|
|
|
|
if (rgDispId[idx] == DISPID_UNKNOWN)
|
2012-11-14 06:26:14 +01:00
|
|
|
FIXME("Unknown member %s, clsid %s\n", debugstr_w(rgszNames[idx]), debugstr_guid(get_riid_from_tid(This->tid)));
|
2007-05-08 00:51:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return hr;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Maximum number of allowed function parameters+1 */
|
|
|
|
#define MAX_FUNC_PARAMS 20
|
|
|
|
|
|
|
|
/* Some error checking is done here to simplify individual object function invocation */
|
|
|
|
static HRESULT WINAPI AutomationObject_Invoke(
|
|
|
|
IDispatch* iface,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IDispatch(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
HRESULT hr;
|
|
|
|
unsigned int uArgErr;
|
|
|
|
VARIANT varResultDummy;
|
|
|
|
BSTR bstrName = NULL;
|
2012-11-14 05:45:02 +01:00
|
|
|
ITypeInfo *ti;
|
2007-05-01 03:53:43 +02:00
|
|
|
|
2016-07-22 12:00:09 +02:00
|
|
|
TRACE("(%p/%p)->(%d, %s, %d, %d, %p, %p, %p, %p)\n", iface, This,
|
|
|
|
dispIdMember, debugstr_guid(riid), lcid, wFlags,
|
|
|
|
pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
if (!IsEqualIID(riid, &IID_NULL))
|
|
|
|
{
|
2007-05-17 18:35:53 +02:00
|
|
|
ERR("riid was %s instead of IID_NULL\n", debugstr_guid(riid));
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET && !pVarResult)
|
|
|
|
{
|
2007-05-17 18:35:53 +02:00
|
|
|
ERR("NULL pVarResult not allowed when DISPATCH_PROPERTYGET specified\n");
|
|
|
|
return DISP_E_PARAMNOTOPTIONAL;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This simplifies our individual object invocation functions */
|
|
|
|
if (puArgErr == NULL) puArgErr = &uArgErr;
|
|
|
|
if (pVarResult == NULL) pVarResult = &varResultDummy;
|
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
hr = get_typeinfo(This->tid, &ti);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2007-05-01 03:53:43 +02:00
|
|
|
/* Assume return type is void unless determined otherwise */
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
|
|
|
|
/* If we are tracing, we want to see the name of the member we are invoking */
|
|
|
|
if (TRACE_ON(msi))
|
|
|
|
{
|
2012-11-14 05:45:02 +01:00
|
|
|
ITypeInfo_GetDocumentation(ti, dispIdMember, &bstrName, NULL, NULL, NULL);
|
2007-05-17 18:35:53 +02:00
|
|
|
TRACE("Method %d, %s\n", dispIdMember, debugstr_w(bstrName));
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = tid_ids[This->tid].fn_invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
if (hr == DISP_E_MEMBERNOTFOUND) {
|
2012-11-14 05:45:02 +01:00
|
|
|
if (bstrName == NULL) ITypeInfo_GetDocumentation(ti, dispIdMember, &bstrName, NULL, NULL, NULL);
|
2012-11-14 06:26:14 +01:00
|
|
|
FIXME("Method %d, %s wflags %d not implemented, clsid %s\n", dispIdMember, debugstr_w(bstrName), wFlags,
|
|
|
|
debugstr_guid(get_riid_from_tid(This->tid)));
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
else if (pExcepInfo &&
|
|
|
|
(hr == DISP_E_PARAMNOTFOUND ||
|
|
|
|
hr == DISP_E_EXCEPTION)) {
|
|
|
|
static const WCHAR szComma[] = { ',',0 };
|
2008-05-26 06:06:47 +02:00
|
|
|
static const WCHAR szExceptionSource[] = {'M','s','i',' ','A','P','I',' ','E','r','r','o','r',0};
|
2007-05-01 03:53:43 +02:00
|
|
|
WCHAR szExceptionDescription[MAX_PATH];
|
|
|
|
BSTR bstrParamNames[MAX_FUNC_PARAMS];
|
|
|
|
unsigned namesNo, i;
|
|
|
|
BOOL bFirst = TRUE;
|
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
if (FAILED(ITypeInfo_GetNames(ti, dispIdMember, bstrParamNames,
|
2007-05-01 03:53:43 +02:00
|
|
|
MAX_FUNC_PARAMS, &namesNo)))
|
|
|
|
{
|
|
|
|
TRACE("Failed to retrieve names for dispIdMember %d\n", dispIdMember);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset(szExceptionDescription, 0, sizeof(szExceptionDescription));
|
|
|
|
for (i=0; i<namesNo; i++)
|
|
|
|
{
|
|
|
|
if (bFirst) bFirst = FALSE;
|
|
|
|
else {
|
|
|
|
lstrcpyW(&szExceptionDescription[lstrlenW(szExceptionDescription)], szComma);
|
|
|
|
}
|
|
|
|
lstrcpyW(&szExceptionDescription[lstrlenW(szExceptionDescription)], bstrParamNames[i]);
|
|
|
|
SysFreeString(bstrParamNames[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(pExcepInfo, 0, sizeof(EXCEPINFO));
|
|
|
|
pExcepInfo->wCode = 1000;
|
2007-07-28 06:51:47 +02:00
|
|
|
pExcepInfo->bstrSource = SysAllocString(szExceptionSource);
|
|
|
|
pExcepInfo->bstrDescription = SysAllocString(szExceptionDescription);
|
2007-05-01 03:53:43 +02:00
|
|
|
hr = DISP_E_EXCEPTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure we free the return variant if it is our dummy variant */
|
|
|
|
if (pVarResult == &varResultDummy) VariantClear(pVarResult);
|
|
|
|
|
|
|
|
/* Free function name if we retrieved it */
|
2008-09-21 15:58:28 +02:00
|
|
|
SysFreeString(bstrName);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
TRACE("Returning 0x%08x, %s\n", hr, SUCCEEDED(hr) ? "ok" : "not ok");
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static const struct IDispatchVtbl AutomationObjectVtbl =
|
2007-05-01 03:53:43 +02:00
|
|
|
{
|
|
|
|
AutomationObject_QueryInterface,
|
|
|
|
AutomationObject_AddRef,
|
|
|
|
AutomationObject_Release,
|
|
|
|
AutomationObject_GetTypeInfoCount,
|
|
|
|
AutomationObject_GetTypeInfo,
|
|
|
|
AutomationObject_GetIDsOfNames,
|
|
|
|
AutomationObject_Invoke
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IProvideMultipleClassInfo methods
|
|
|
|
*/
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static HRESULT WINAPI ProvideMultipleClassInfo_QueryInterface(
|
2007-05-01 03:53:43 +02:00
|
|
|
IProvideMultipleClassInfo* iface,
|
|
|
|
REFIID riid,
|
|
|
|
VOID** ppvoid)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
|
|
|
|
return IDispatch_QueryInterface(&This->IDispatch_iface, riid, ppvoid);
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static ULONG WINAPI ProvideMultipleClassInfo_AddRef(IProvideMultipleClassInfo* iface)
|
2007-05-01 03:53:43 +02:00
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
|
|
|
|
return IDispatch_AddRef(&This->IDispatch_iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static ULONG WINAPI ProvideMultipleClassInfo_Release(IProvideMultipleClassInfo* iface)
|
2007-05-01 03:53:43 +02:00
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
|
|
|
|
return IDispatch_Release(&This->IDispatch_iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static HRESULT WINAPI ProvideMultipleClassInfo_GetClassInfo(IProvideMultipleClassInfo* iface, ITypeInfo** ppTI)
|
2007-05-01 03:53:43 +02:00
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
|
2012-11-14 05:45:02 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2007-05-01 03:53:43 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", iface, This, ppTI);
|
2012-11-14 05:45:02 +01:00
|
|
|
|
|
|
|
hr = get_typeinfo(This->tid, ppTI);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
ITypeInfo_AddRef(*ppTI);
|
|
|
|
|
|
|
|
return hr;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static HRESULT WINAPI ProvideMultipleClassInfo_GetGUID(IProvideMultipleClassInfo* iface, DWORD dwGuidKind, GUID* pGUID)
|
2007-05-01 03:53:43 +02:00
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
TRACE("(%p/%p)->(%d,%s)\n", iface, This, dwGuidKind, debugstr_guid(pGUID));
|
|
|
|
|
|
|
|
if (dwGuidKind != GUIDKIND_DEFAULT_SOURCE_DISP_IID)
|
2007-05-17 18:35:53 +02:00
|
|
|
return E_INVALIDARG;
|
2007-05-01 03:53:43 +02:00
|
|
|
else {
|
2012-11-14 06:26:14 +01:00
|
|
|
*pGUID = *get_riid_from_tid(This->tid);
|
2007-05-17 18:35:53 +02:00
|
|
|
return S_OK;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static HRESULT WINAPI ProvideMultipleClassInfo_GetMultiTypeInfoCount(IProvideMultipleClassInfo* iface, ULONG* pcti)
|
2007-05-01 03:53:43 +02:00
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%p)\n", iface, This, pcti);
|
|
|
|
*pcti = 1;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static HRESULT WINAPI ProvideMultipleClassInfo_GetInfoOfIndex(IProvideMultipleClassInfo* iface,
|
2007-05-01 03:53:43 +02:00
|
|
|
ULONG iti,
|
|
|
|
DWORD dwFlags,
|
2012-11-14 05:45:02 +01:00
|
|
|
ITypeInfo** ti,
|
2007-05-01 03:53:43 +02:00
|
|
|
DWORD* pdwTIFlags,
|
|
|
|
ULONG* pcdispidReserved,
|
|
|
|
IID* piidPrimary,
|
|
|
|
IID* piidSource)
|
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
AutomationObject *This = impl_from_IProvideMultipleClassInfo(iface);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
TRACE("(%p/%p)->(%d,%d,%p,%p,%p,%p,%p)\n", iface, This, iti, dwFlags, ti, pdwTIFlags, pcdispidReserved, piidPrimary, piidSource);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
if (iti != 0)
|
2007-05-17 18:35:53 +02:00
|
|
|
return E_INVALIDARG;
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
if (dwFlags & MULTICLASSINFO_GETTYPEINFO)
|
2012-11-14 05:45:02 +01:00
|
|
|
{
|
|
|
|
HRESULT hr = get_typeinfo(This->tid, ti);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
ITypeInfo_AddRef(*ti);
|
|
|
|
}
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
if (dwFlags & MULTICLASSINFO_GETNUMRESERVEDDISPIDS)
|
|
|
|
{
|
2007-05-17 18:35:53 +02:00
|
|
|
*pdwTIFlags = 0;
|
|
|
|
*pcdispidReserved = 0;
|
2007-05-01 03:53:43 +02:00
|
|
|
}
|
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
if (dwFlags & MULTICLASSINFO_GETIIDPRIMARY)
|
2012-11-14 06:26:14 +01:00
|
|
|
*piidPrimary = *get_riid_from_tid(This->tid);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
if (dwFlags & MULTICLASSINFO_GETIIDSOURCE)
|
2012-11-14 06:26:14 +01:00
|
|
|
*piidSource = *get_riid_from_tid(This->tid);
|
2007-05-01 03:53:43 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
static const IProvideMultipleClassInfoVtbl ProvideMultipleClassInfoVtbl =
|
2007-05-01 03:53:43 +02:00
|
|
|
{
|
2012-01-14 12:06:17 +01:00
|
|
|
ProvideMultipleClassInfo_QueryInterface,
|
|
|
|
ProvideMultipleClassInfo_AddRef,
|
|
|
|
ProvideMultipleClassInfo_Release,
|
|
|
|
ProvideMultipleClassInfo_GetClassInfo,
|
|
|
|
ProvideMultipleClassInfo_GetGUID,
|
|
|
|
ProvideMultipleClassInfo_GetMultiTypeInfoCount,
|
|
|
|
ProvideMultipleClassInfo_GetInfoOfIndex
|
2007-05-01 03:53:43 +02:00
|
|
|
};
|
2007-05-01 03:53:55 +02:00
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static HRESULT init_automation_object(AutomationObject *This, MSIHANDLE msiHandle, tid_t tid)
|
2012-01-14 14:34:13 +01:00
|
|
|
{
|
2012-11-14 06:26:14 +01:00
|
|
|
TRACE("(%p, %d, %s)\n", This, msiHandle, debugstr_guid(get_riid_from_tid(tid)));
|
2012-01-14 14:34:13 +01:00
|
|
|
|
|
|
|
This->IDispatch_iface.lpVtbl = &AutomationObjectVtbl;
|
|
|
|
This->IProvideMultipleClassInfo_iface.lpVtbl = &ProvideMultipleClassInfoVtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
|
|
|
|
This->msiHandle = msiHandle;
|
2012-11-14 05:45:02 +01:00
|
|
|
This->tid = tid;
|
2012-01-14 14:34:13 +01:00
|
|
|
|
2012-11-14 05:45:02 +01:00
|
|
|
return S_OK;
|
2012-01-14 14:34:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-18 18:23:19 +02:00
|
|
|
/*
|
|
|
|
* ListEnumerator methods
|
|
|
|
*/
|
|
|
|
|
2011-09-02 10:24:01 +02:00
|
|
|
static inline ListEnumerator *impl_from_IEnumVARIANT(IEnumVARIANT* iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ListEnumerator, IEnumVARIANT_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ListEnumerator_QueryInterface(IEnumVARIANT* iface, REFIID riid,
|
|
|
|
void** ppvObject)
|
2007-05-18 18:23:19 +02:00
|
|
|
{
|
2011-09-02 10:24:01 +02:00
|
|
|
ListEnumerator *This = impl_from_IEnumVARIANT(iface);
|
2007-05-18 18:23:19 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
|
|
|
|
|
|
|
if (ppvObject == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppvObject = 0;
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IEnumVARIANT))
|
|
|
|
{
|
|
|
|
*ppvObject = &This->IEnumVARIANT_iface;
|
|
|
|
}
|
2007-05-18 18:23:19 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("() : asking for unsupported interface %s\n",debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
IEnumVARIANT_AddRef(iface);
|
2007-05-18 18:23:19 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ListEnumerator_AddRef(IEnumVARIANT* iface)
|
|
|
|
{
|
2011-09-02 10:24:01 +02:00
|
|
|
ListEnumerator *This = impl_from_IEnumVARIANT(iface);
|
2007-05-18 18:23:19 +02:00
|
|
|
|
|
|
|
TRACE("(%p/%p)\n", iface, This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ListEnumerator_Release(IEnumVARIANT* iface)
|
|
|
|
{
|
2011-09-02 10:24:01 +02:00
|
|
|
ListEnumerator *This = impl_from_IEnumVARIANT(iface);
|
2007-05-18 18:23:19 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p/%p)\n", iface, This);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
2012-01-14 23:32:01 +01:00
|
|
|
if (This->list) IDispatch_Release(&This->list->autoobj.IDispatch_iface);
|
2010-05-20 12:01:50 +02:00
|
|
|
msi_free(This);
|
2007-05-18 18:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2011-09-02 10:24:01 +02:00
|
|
|
static HRESULT WINAPI ListEnumerator_Next(IEnumVARIANT* iface, ULONG celt, VARIANT* rgVar,
|
2012-01-14 23:32:01 +01:00
|
|
|
ULONG* fetched)
|
2007-05-18 18:23:19 +02:00
|
|
|
{
|
2011-09-02 10:24:01 +02:00
|
|
|
ListEnumerator *This = impl_from_IEnumVARIANT(iface);
|
2012-01-14 23:32:01 +01:00
|
|
|
ULONG i, local;
|
2007-05-18 18:23:19 +02:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
TRACE("(%p, %uld, %p, %p)\n", iface, celt, rgVar, fetched);
|
2007-05-18 18:23:19 +02:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
if (fetched) *fetched = 0;
|
2007-05-18 18:23:19 +02:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
if (!rgVar)
|
2007-05-18 18:23:19 +02:00
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
for (local = 0; local < celt; local++)
|
|
|
|
VariantInit(&rgVar[local]);
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
for (i = This->pos, local = 0; i < This->list->count && local < celt; i++, local++)
|
|
|
|
VariantCopy(&rgVar[local], &This->list->data[i]);
|
2007-05-18 18:23:19 +02:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
if (fetched) *fetched = local;
|
|
|
|
This->pos = i;
|
2007-05-18 18:23:19 +02:00
|
|
|
|
|
|
|
return (local < celt) ? S_FALSE : S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ListEnumerator_Skip(IEnumVARIANT* iface, ULONG celt)
|
|
|
|
{
|
2011-09-02 10:24:01 +02:00
|
|
|
ListEnumerator *This = impl_from_IEnumVARIANT(iface);
|
2007-05-18 18:23:19 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%uld)\n", iface, celt);
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
This->pos += celt;
|
|
|
|
if (This->pos >= This->list->count)
|
2007-05-18 18:23:19 +02:00
|
|
|
{
|
2012-01-14 23:32:01 +01:00
|
|
|
This->pos = This->list->count;
|
2007-05-18 18:23:19 +02:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
2012-01-14 23:32:01 +01:00
|
|
|
|
2007-05-18 18:23:19 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ListEnumerator_Reset(IEnumVARIANT* iface)
|
|
|
|
{
|
2011-09-02 10:24:01 +02:00
|
|
|
ListEnumerator *This = impl_from_IEnumVARIANT(iface);
|
2007-05-18 18:23:19 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", iface);
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
This->pos = 0;
|
2007-05-18 18:23:19 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ListEnumerator_Clone(IEnumVARIANT* iface, IEnumVARIANT **ppEnum)
|
|
|
|
{
|
2011-09-02 10:24:01 +02:00
|
|
|
ListEnumerator *This = impl_from_IEnumVARIANT(iface);
|
2007-05-18 18:23:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", iface, ppEnum);
|
|
|
|
|
|
|
|
if (ppEnum == NULL)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
*ppEnum = NULL;
|
2012-01-14 23:32:01 +01:00
|
|
|
hr = create_list_enumerator(This->list, (LPVOID *)ppEnum);
|
2007-05-18 18:23:19 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-07-27 14:03:12 +02:00
|
|
|
if (*ppEnum) IEnumVARIANT_Release(*ppEnum);
|
2007-05-18 18:23:19 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IEnumVARIANTVtbl ListEnumerator_Vtbl =
|
|
|
|
{
|
|
|
|
ListEnumerator_QueryInterface,
|
|
|
|
ListEnumerator_AddRef,
|
|
|
|
ListEnumerator_Release,
|
|
|
|
ListEnumerator_Next,
|
|
|
|
ListEnumerator_Skip,
|
|
|
|
ListEnumerator_Reset,
|
|
|
|
ListEnumerator_Clone
|
|
|
|
};
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
/* Create a list enumerator, placing the result in the pointer ppObj. */
|
2012-01-14 23:32:01 +01:00
|
|
|
static HRESULT create_list_enumerator(ListObject *list, void **ppObj)
|
2012-01-14 12:06:17 +01:00
|
|
|
{
|
|
|
|
ListEnumerator *object;
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
TRACE("(%p, %p)\n", list, ppObj);
|
2012-01-14 12:06:17 +01:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
object = msi_alloc(sizeof(ListEnumerator));
|
2012-01-14 12:06:17 +01:00
|
|
|
|
|
|
|
/* Set all the VTable references */
|
|
|
|
object->IEnumVARIANT_iface.lpVtbl = &ListEnumerator_Vtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
|
|
|
|
/* Store data that was passed */
|
2012-01-14 23:32:01 +01:00
|
|
|
object->pos = 0;
|
|
|
|
object->list = list;
|
|
|
|
if (list) IDispatch_AddRef(&list->autoobj.IDispatch_iface);
|
2012-01-14 12:06:17 +01:00
|
|
|
|
|
|
|
*ppObj = object;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-05-01 03:53:55 +02:00
|
|
|
/*
|
|
|
|
* Individual Object Invocation Functions
|
|
|
|
*/
|
|
|
|
|
2007-05-10 22:40:28 +02:00
|
|
|
/* Helper function that copies a passed parameter instead of using VariantChangeType like the actual DispGetParam.
|
|
|
|
This function is only for VARIANT type parameters that have several types that cannot be properly discriminated
|
|
|
|
using DispGetParam/VariantChangeType. */
|
2008-11-26 17:15:59 +01:00
|
|
|
static HRESULT DispGetParam_CopyOnly(
|
2007-05-17 18:35:53 +02:00
|
|
|
DISPPARAMS *pdispparams, /* [in] Parameter list */
|
|
|
|
UINT *position, /* [in] Position of parameter to copy in pdispparams; on return will contain calculated position */
|
|
|
|
VARIANT *pvarResult) /* [out] Destination for resulting variant */
|
2007-05-10 22:40:28 +02:00
|
|
|
{
|
|
|
|
/* position is counted backwards */
|
|
|
|
UINT pos;
|
|
|
|
|
|
|
|
TRACE("position=%d, cArgs=%d, cNamedArgs=%d\n",
|
|
|
|
*position, pdispparams->cArgs, pdispparams->cNamedArgs);
|
|
|
|
if (*position < pdispparams->cArgs) {
|
|
|
|
/* positional arg? */
|
|
|
|
pos = pdispparams->cArgs - *position - 1;
|
|
|
|
} else {
|
|
|
|
/* FIXME: is this how to handle named args? */
|
|
|
|
for (pos=0; pos<pdispparams->cNamedArgs; pos++)
|
|
|
|
if (pdispparams->rgdispidNamedArgs[pos] == *position) break;
|
|
|
|
|
|
|
|
if (pos==pdispparams->cNamedArgs)
|
|
|
|
return DISP_E_PARAMNOTFOUND;
|
|
|
|
}
|
|
|
|
*position = pos;
|
|
|
|
return VariantCopyInd(pvarResult,
|
|
|
|
&pdispparams->rgvarg[pos]);
|
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static HRESULT summaryinfo_invoke(
|
2007-06-01 04:52:05 +02:00
|
|
|
AutomationObject* This,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
UINT ret;
|
2007-06-04 16:26:45 +02:00
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
FILETIME ft, ftlocal;
|
|
|
|
SYSTEMTIME st;
|
2007-06-01 04:52:05 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
2007-06-04 16:26:45 +02:00
|
|
|
VariantInit(&varg1);
|
2007-06-01 04:52:05 +02:00
|
|
|
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
|
|
|
case DISPID_SUMMARYINFO_PROPERTY:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET)
|
|
|
|
{
|
|
|
|
UINT type;
|
|
|
|
INT value;
|
2007-06-04 16:25:59 +02:00
|
|
|
DWORD size = 0;
|
|
|
|
DATE date;
|
|
|
|
LPWSTR str;
|
2007-06-01 04:52:05 +02:00
|
|
|
|
|
|
|
static WCHAR szEmpty[] = {0};
|
|
|
|
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
2007-06-04 16:25:59 +02:00
|
|
|
ret = MsiSummaryInfoGetPropertyW(This->msiHandle, V_I4(&varg0), &type, &value,
|
|
|
|
&ft, szEmpty, &size);
|
|
|
|
if (ret != ERROR_SUCCESS &&
|
|
|
|
ret != ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
ERR("MsiSummaryInfoGetProperty returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-06-01 04:52:05 +02:00
|
|
|
|
2007-06-04 16:25:59 +02:00
|
|
|
switch (type)
|
2007-06-01 04:52:05 +02:00
|
|
|
{
|
2007-06-04 16:25:59 +02:00
|
|
|
case VT_EMPTY:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_I2:
|
|
|
|
case VT_I4:
|
2007-06-01 04:52:05 +02:00
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = value;
|
2007-06-04 16:25:59 +02:00
|
|
|
break;
|
2007-06-01 04:52:05 +02:00
|
|
|
|
2007-06-04 16:25:59 +02:00
|
|
|
case VT_LPSTR:
|
2007-06-02 03:06:55 +02:00
|
|
|
if (!(str = msi_alloc(++size * sizeof(WCHAR))))
|
|
|
|
ERR("Out of memory\n");
|
2007-06-04 16:25:59 +02:00
|
|
|
else if ((ret = MsiSummaryInfoGetPropertyW(This->msiHandle, V_I4(&varg0), &type, NULL,
|
|
|
|
NULL, str, &size)) != ERROR_SUCCESS)
|
|
|
|
ERR("MsiSummaryInfoGetProperty returned %d\n", ret);
|
|
|
|
else
|
2007-06-02 03:06:55 +02:00
|
|
|
{
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(str);
|
|
|
|
}
|
2007-06-01 04:52:05 +02:00
|
|
|
msi_free(str);
|
2007-06-04 16:25:59 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_FILETIME:
|
2007-06-02 03:06:55 +02:00
|
|
|
FileTimeToLocalFileTime(&ft, &ftlocal);
|
|
|
|
FileTimeToSystemTime(&ftlocal, &st);
|
|
|
|
SystemTimeToVariantTime(&st, &date);
|
2007-06-01 04:52:05 +02:00
|
|
|
|
2007-06-02 03:06:55 +02:00
|
|
|
V_VT(pVarResult) = VT_DATE;
|
|
|
|
V_DATE(pVarResult) = date;
|
2007-06-04 16:25:59 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ERR("Unhandled variant type %d\n", type);
|
2007-06-01 04:52:05 +02:00
|
|
|
}
|
|
|
|
}
|
2007-06-04 16:26:45 +02:00
|
|
|
else if (wFlags & DISPATCH_PROPERTYPUT)
|
|
|
|
{
|
|
|
|
UINT posValue = DISPID_PROPERTYPUT;
|
|
|
|
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
hr = DispGetParam_CopyOnly(pDispParams, &posValue, &varg1);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*puArgErr = posValue;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (V_VT(&varg1))
|
|
|
|
{
|
|
|
|
case VT_I2:
|
|
|
|
case VT_I4:
|
|
|
|
ret = MsiSummaryInfoSetPropertyW(This->msiHandle, V_I4(&varg0), V_VT(&varg1), V_I4(&varg1), NULL, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_DATE:
|
|
|
|
VariantTimeToSystemTime(V_DATE(&varg1), &st);
|
|
|
|
SystemTimeToFileTime(&st, &ftlocal);
|
|
|
|
LocalFileTimeToFileTime(&ftlocal, &ft);
|
|
|
|
ret = MsiSummaryInfoSetPropertyW(This->msiHandle, V_I4(&varg0), VT_FILETIME, 0, &ft, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_BSTR:
|
|
|
|
ret = MsiSummaryInfoSetPropertyW(This->msiHandle, V_I4(&varg0), VT_LPSTR, 0, NULL, V_BSTR(&varg1));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled variant type %d\n", V_VT(&varg1));
|
|
|
|
VariantClear(&varg1);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("MsiSummaryInfoSetPropertyW returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
|
|
|
}
|
2007-06-01 04:52:05 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
|
|
|
break;
|
|
|
|
|
2007-06-04 16:26:51 +02:00
|
|
|
case DISPID_SUMMARYINFO_PROPERTYCOUNT:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
|
|
|
UINT count;
|
|
|
|
if ((ret = MsiSummaryInfoGetPropertyCount(This->msiHandle, &count)) != ERROR_SUCCESS)
|
|
|
|
ERR("MsiSummaryInfoGetPropertyCount returned %d\n", ret);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
|
|
|
break;
|
|
|
|
|
2007-06-01 04:52:05 +02:00
|
|
|
default:
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
2007-06-04 16:26:45 +02:00
|
|
|
VariantClear(&varg1);
|
2007-06-01 04:52:05 +02:00
|
|
|
VariantClear(&varg0);
|
2007-06-04 16:26:45 +02:00
|
|
|
|
2007-06-01 04:52:05 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static HRESULT record_invoke(
|
2007-05-01 03:53:55 +02:00
|
|
|
AutomationObject* This,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
WCHAR *szString;
|
2012-11-09 16:46:52 +01:00
|
|
|
DWORD dwLen = 0;
|
2007-05-01 03:53:55 +02:00
|
|
|
UINT ret;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
VariantInit(&varg1);
|
|
|
|
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_RECORD_FIELDCOUNT:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-11 21:08:14 +02:00
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = MsiRecordGetFieldCount(This->msiHandle);
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:14 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-11 21:08:14 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_RECORD_STRINGDATA:
|
2007-05-16 02:29:04 +02:00
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-01 03:53:55 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = NULL;
|
2007-05-16 02:29:04 +02:00
|
|
|
if ((ret = MsiRecordGetStringW(This->msiHandle, V_I4(&varg0), NULL, &dwLen)) == ERROR_SUCCESS)
|
2007-05-01 03:53:55 +02:00
|
|
|
{
|
2007-05-16 02:29:04 +02:00
|
|
|
if (!(szString = msi_alloc((++dwLen)*sizeof(WCHAR))))
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
else if ((ret = MsiRecordGetStringW(This->msiHandle, V_I4(&varg0), szString, &dwLen)) == ERROR_SUCCESS)
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(szString);
|
|
|
|
msi_free(szString);
|
2007-05-01 03:53:55 +02:00
|
|
|
}
|
|
|
|
if (ret != ERROR_SUCCESS)
|
2007-05-16 02:29:04 +02:00
|
|
|
ERR("MsiRecordGetString returned %d\n", ret);
|
2007-05-17 18:35:53 +02:00
|
|
|
} else if (wFlags & DISPATCH_PROPERTYPUT) {
|
2007-05-01 03:53:55 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
2012-05-01 12:39:17 +02:00
|
|
|
hr = DispGetParam(pDispParams, 1, VT_BSTR, &varg1, puArgErr);
|
2007-05-01 03:53:55 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
2007-05-17 18:35:53 +02:00
|
|
|
if ((ret = MsiRecordSetStringW(This->msiHandle, V_I4(&varg0), V_BSTR(&varg1))) != ERROR_SUCCESS)
|
2007-05-01 03:53:55 +02:00
|
|
|
{
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg1);
|
2007-05-01 03:53:55 +02:00
|
|
|
ERR("MsiRecordSetString returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:53:55 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_RECORD_INTEGERDATA:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-14 19:14:00 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = MsiRecordGetInteger(This->msiHandle, V_I4(&varg0));
|
2007-05-17 18:35:53 +02:00
|
|
|
} else if (wFlags & DISPATCH_PROPERTYPUT) {
|
2007-05-14 19:14:00 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
2012-05-01 12:39:17 +02:00
|
|
|
hr = DispGetParam(pDispParams, 1, VT_I4, &varg1, puArgErr);
|
2007-05-14 19:14:00 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
if ((ret = MsiRecordSetInteger(This->msiHandle, V_I4(&varg0), V_I4(&varg1))) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("MsiRecordSetInteger returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-14 19:14:00 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-14 19:14:00 +02:00
|
|
|
|
2007-05-01 03:53:55 +02:00
|
|
|
default:
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg1);
|
|
|
|
VariantClear(&varg0);
|
|
|
|
|
2007-05-01 03:53:55 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2007-05-01 03:54:02 +02:00
|
|
|
|
2012-04-20 08:40:15 +02:00
|
|
|
static HRESULT create_record(MSIHANDLE msiHandle, IDispatch **disp)
|
2012-01-17 00:12:30 +01:00
|
|
|
{
|
|
|
|
AutomationObject *record;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
record = msi_alloc(sizeof(*record));
|
|
|
|
if (!record) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = init_automation_object(record, msiHandle, Record_tid);
|
2012-01-17 00:12:30 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
msi_free(record);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*disp = &record->IDispatch_iface;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static HRESULT list_invoke(
|
2007-05-08 00:50:30 +02:00
|
|
|
AutomationObject* This,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2016-09-08 22:21:04 +02:00
|
|
|
ListObject *list = CONTAINING_RECORD(This, ListObject, autoobj);
|
2007-05-18 18:23:19 +02:00
|
|
|
IUnknown *pUnk = NULL;
|
2012-01-14 23:32:01 +01:00
|
|
|
HRESULT hr;
|
2007-05-08 00:50:30 +02:00
|
|
|
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
2007-05-18 18:23:19 +02:00
|
|
|
case DISPID_LIST__NEWENUM:
|
|
|
|
if (wFlags & DISPATCH_METHOD) {
|
|
|
|
V_VT(pVarResult) = VT_UNKNOWN;
|
2012-01-14 23:32:01 +01:00
|
|
|
if (SUCCEEDED(hr = create_list_enumerator(list, (LPVOID *)&pUnk)))
|
2007-05-18 18:23:19 +02:00
|
|
|
V_UNKNOWN(pVarResult) = pUnk;
|
|
|
|
else
|
|
|
|
ERR("Failed to create IEnumVARIANT object, hresult 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
|
|
|
break;
|
|
|
|
|
2007-05-18 18:23:01 +02:00
|
|
|
case DISPID_LIST_ITEM:
|
2007-05-18 18:23:19 +02:00
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2012-01-14 23:32:01 +01:00
|
|
|
VARIANTARG index;
|
|
|
|
|
|
|
|
VariantInit(&index);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &index, puArgErr);
|
2007-05-08 00:50:30 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
2012-01-14 23:32:01 +01:00
|
|
|
if (V_I4(&index) < 0 || V_I4(&index) >= list->count)
|
2007-05-08 00:50:30 +02:00
|
|
|
return DISP_E_BADINDEX;
|
2012-01-14 23:32:01 +01:00
|
|
|
VariantCopy(pVarResult, &list->data[V_I4(&index)]);
|
2007-05-08 00:50:30 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-08 00:50:30 +02:00
|
|
|
break;
|
|
|
|
|
2007-05-18 18:23:01 +02:00
|
|
|
case DISPID_LIST_COUNT:
|
2007-05-17 18:35:53 +02:00
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-08 00:50:30 +02:00
|
|
|
V_VT(pVarResult) = VT_I4;
|
2012-01-14 23:32:01 +01:00
|
|
|
V_I4(pVarResult) = list->count;
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-08 00:50:30 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static void list_free(AutomationObject *This)
|
2007-05-08 00:50:30 +02:00
|
|
|
{
|
2016-09-08 22:21:04 +02:00
|
|
|
ListObject *list = CONTAINING_RECORD(This, ListObject, autoobj);
|
2012-01-14 23:32:01 +01:00
|
|
|
int i;
|
2007-05-08 00:50:30 +02:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
for (i = 0; i < list->count; i++)
|
|
|
|
VariantClear(&list->data[i]);
|
|
|
|
msi_free(list->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT get_products_count(const WCHAR *product, int *len)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
WCHAR dataW[GUID_SIZE];
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
/* all or related only */
|
|
|
|
if (product)
|
|
|
|
ret = MsiEnumRelatedProductsW(product, 0, i, dataW);
|
|
|
|
else
|
|
|
|
ret = MsiEnumProductsW(i, dataW);
|
|
|
|
|
|
|
|
if (ret == ERROR_NO_MORE_ITEMS) break;
|
|
|
|
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*len = i;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT create_list(const WCHAR *product, IDispatch **dispatch)
|
|
|
|
{
|
|
|
|
ListObject *list;
|
|
|
|
HRESULT hr;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
list = msi_alloc_zero(sizeof(ListObject));
|
|
|
|
if (!list) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = init_automation_object(&list->autoobj, 0, StringList_tid);
|
2012-01-14 23:32:01 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
msi_free(list);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*dispatch = &list->autoobj.IDispatch_iface;
|
|
|
|
|
|
|
|
hr = get_products_count(product, &list->count);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
IDispatch_Release(*dispatch);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
list->data = msi_alloc(list->count*sizeof(VARIANT));
|
|
|
|
if (!list->data)
|
|
|
|
{
|
|
|
|
IDispatch_Release(*dispatch);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < list->count; i++)
|
|
|
|
{
|
|
|
|
WCHAR dataW[GUID_SIZE];
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
/* all or related only */
|
|
|
|
if (product)
|
|
|
|
ret = MsiEnumRelatedProductsW(product, 0, i, dataW);
|
|
|
|
else
|
|
|
|
ret = MsiEnumProductsW(i, dataW);
|
|
|
|
|
|
|
|
if (ret == ERROR_NO_MORE_ITEMS) break;
|
|
|
|
|
|
|
|
V_VT(&list->data[i]) = VT_BSTR;
|
|
|
|
V_BSTR(&list->data[i]) = SysAllocString(dataW);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2007-05-08 00:50:30 +02:00
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static HRESULT view_invoke(
|
2007-05-01 03:54:02 +02:00
|
|
|
AutomationObject* This,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
MSIHANDLE msiHandle;
|
|
|
|
UINT ret;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
VariantInit(&varg1);
|
|
|
|
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_VIEW_EXECUTE:
|
|
|
|
if (wFlags & DISPATCH_METHOD)
|
|
|
|
{
|
2007-05-01 03:54:02 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &varg0, puArgErr);
|
|
|
|
if (SUCCEEDED(hr) && V_DISPATCH(&varg0) != NULL)
|
|
|
|
MsiViewExecute(This->msiHandle, ((AutomationObject *)V_DISPATCH(&varg0))->msiHandle);
|
|
|
|
else
|
|
|
|
MsiViewExecute(This->msiHandle, 0);
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:02 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_VIEW_FETCH:
|
|
|
|
if (wFlags & DISPATCH_METHOD)
|
|
|
|
{
|
2007-05-01 03:54:02 +02:00
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
|
|
|
if ((ret = MsiViewFetch(This->msiHandle, &msiHandle)) == ERROR_SUCCESS)
|
|
|
|
{
|
2013-03-13 12:47:30 +01:00
|
|
|
if (FAILED(hr = create_record(msiHandle, &V_DISPATCH(pVarResult))))
|
2007-05-08 00:52:53 +02:00
|
|
|
ERR("Failed to create Record object, hresult 0x%08x\n", hr);
|
2007-05-01 03:54:02 +02:00
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
else if (ret == ERROR_NO_MORE_ITEMS)
|
2007-05-01 03:54:02 +02:00
|
|
|
V_DISPATCH(pVarResult) = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("MsiViewFetch returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
2007-05-11 21:08:43 +02:00
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:43 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-11 21:08:43 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_VIEW_MODIFY:
|
|
|
|
if (wFlags & DISPATCH_METHOD)
|
|
|
|
{
|
2007-05-11 21:08:43 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_DISPATCH, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
if (!V_DISPATCH(&varg1)) return DISP_E_EXCEPTION;
|
|
|
|
if ((ret = MsiViewModify(This->msiHandle, V_I4(&varg0), ((AutomationObject *)V_DISPATCH(&varg1))->msiHandle)) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
VariantClear(&varg1);
|
|
|
|
ERR("MsiViewModify returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
2007-05-01 03:54:02 +02:00
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:02 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_VIEW_CLOSE:
|
|
|
|
if (wFlags & DISPATCH_METHOD)
|
|
|
|
{
|
|
|
|
MsiViewClose(This->msiHandle);
|
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:02 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg1);
|
|
|
|
VariantClear(&varg0);
|
|
|
|
|
2007-05-01 03:54:02 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2007-05-01 03:54:09 +02:00
|
|
|
|
2010-02-03 18:09:20 +01:00
|
|
|
static HRESULT DatabaseImpl_LastErrorRecord(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
HRESULT database_invoke(
|
2007-05-01 03:54:09 +02:00
|
|
|
AutomationObject* This,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2012-01-17 00:12:30 +01:00
|
|
|
IDispatch *dispatch = NULL;
|
2007-05-01 03:54:09 +02:00
|
|
|
MSIHANDLE msiHandle;
|
|
|
|
UINT ret;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
VariantInit(&varg1);
|
|
|
|
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
2007-06-01 04:52:05 +02:00
|
|
|
case DISPID_DATABASE_SUMMARYINFORMATION:
|
2007-06-02 03:06:37 +02:00
|
|
|
if (wFlags & DISPATCH_PROPERTYGET)
|
2007-06-01 04:52:05 +02:00
|
|
|
{
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
V_I4(&varg0) = 0;
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
|
|
|
if ((ret = MsiGetSummaryInformationW(This->msiHandle, NULL, V_I4(&varg0), &msiHandle)) == ERROR_SUCCESS)
|
|
|
|
{
|
2012-01-17 00:12:30 +01:00
|
|
|
hr = create_summaryinfo(msiHandle, &dispatch);
|
2007-06-01 04:52:05 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2012-01-17 00:12:30 +01:00
|
|
|
V_DISPATCH(pVarResult) = dispatch;
|
2007-06-01 04:52:05 +02:00
|
|
|
else
|
|
|
|
ERR("Failed to create SummaryInfo object: 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("MsiGetSummaryInformation returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
|
|
|
break;
|
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_DATABASE_OPENVIEW:
|
|
|
|
if (wFlags & DISPATCH_METHOD)
|
|
|
|
{
|
2007-05-01 03:54:09 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
2007-05-08 14:39:38 +02:00
|
|
|
if ((ret = MsiDatabaseOpenViewW(This->msiHandle, V_BSTR(&varg0), &msiHandle)) == ERROR_SUCCESS)
|
2007-05-01 03:54:09 +02:00
|
|
|
{
|
2012-01-17 00:12:30 +01:00
|
|
|
if (SUCCEEDED(hr = create_view(msiHandle, &dispatch)))
|
|
|
|
V_DISPATCH(pVarResult) = dispatch;
|
2007-05-08 00:52:53 +02:00
|
|
|
else
|
|
|
|
ERR("Failed to create View object, hresult 0x%08x\n", hr);
|
2007-05-01 03:54:09 +02:00
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
else
|
2007-05-01 03:54:09 +02:00
|
|
|
{
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg0);
|
2007-05-01 03:54:09 +02:00
|
|
|
ERR("MsiDatabaseOpenView returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:09 +02:00
|
|
|
|
2010-02-03 18:09:20 +01:00
|
|
|
case DISPID_INSTALLER_LASTERRORRECORD:
|
|
|
|
return DatabaseImpl_LastErrorRecord(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
|
|
|
|
2007-05-01 03:54:09 +02:00
|
|
|
default:
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg1);
|
|
|
|
VariantClear(&varg0);
|
|
|
|
|
2007-05-01 03:54:09 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2007-05-01 03:54:15 +02:00
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static HRESULT session_invoke(
|
2007-05-01 03:54:15 +02:00
|
|
|
AutomationObject* This,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2016-09-08 22:21:04 +02:00
|
|
|
SessionObject *session = CONTAINING_RECORD(This, SessionObject, autoobj);
|
2007-05-01 03:54:15 +02:00
|
|
|
WCHAR *szString;
|
2015-04-21 11:20:42 +02:00
|
|
|
DWORD dwLen = 0;
|
2007-05-01 03:54:15 +02:00
|
|
|
MSIHANDLE msiHandle;
|
|
|
|
LANGID langId;
|
|
|
|
UINT ret;
|
|
|
|
INSTALLSTATE iInstalled, iAction;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
VariantInit(&varg1);
|
|
|
|
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_SESSION_INSTALLER:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-05 06:18:40 +02:00
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
2012-01-14 14:34:13 +01:00
|
|
|
IDispatch_AddRef(session->installer);
|
|
|
|
V_DISPATCH(pVarResult) = session->installer;
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-05 06:18:40 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_SESSION_PROPERTY:
|
2007-05-16 02:29:04 +02:00
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-01 03:54:15 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = NULL;
|
2007-05-16 02:29:04 +02:00
|
|
|
if ((ret = MsiGetPropertyW(This->msiHandle, V_BSTR(&varg0), NULL, &dwLen)) == ERROR_SUCCESS)
|
2007-05-01 03:54:15 +02:00
|
|
|
{
|
2007-05-16 02:29:04 +02:00
|
|
|
if (!(szString = msi_alloc((++dwLen)*sizeof(WCHAR))))
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
else if ((ret = MsiGetPropertyW(This->msiHandle, V_BSTR(&varg0), szString, &dwLen)) == ERROR_SUCCESS)
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(szString);
|
|
|
|
msi_free(szString);
|
2007-05-01 03:54:15 +02:00
|
|
|
}
|
|
|
|
if (ret != ERROR_SUCCESS)
|
2007-05-16 02:29:04 +02:00
|
|
|
ERR("MsiGetProperty returned %d\n", ret);
|
2007-05-17 18:35:53 +02:00
|
|
|
} else if (wFlags & DISPATCH_PROPERTYPUT) {
|
2007-05-01 03:54:15 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
2012-05-01 12:39:17 +02:00
|
|
|
hr = DispGetParam(pDispParams, 1, VT_BSTR, &varg1, puArgErr);
|
2007-05-01 03:54:15 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
VariantClear(&varg0);
|
|
|
|
return hr;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
if ((ret = MsiSetPropertyW(This->msiHandle, V_BSTR(&varg0), V_BSTR(&varg1))) != ERROR_SUCCESS)
|
2007-05-01 03:54:15 +02:00
|
|
|
{
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg0);
|
|
|
|
VariantClear(&varg1);
|
2007-05-01 03:54:15 +02:00
|
|
|
ERR("MsiSetProperty returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:15 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_SESSION_LANGUAGE:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
|
|
|
langId = MsiGetLanguage(This->msiHandle);
|
2007-05-01 03:54:15 +02:00
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = langId;
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:15 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_SESSION_MODE:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-01 03:54:15 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_BOOL;
|
2015-10-21 13:59:49 +02:00
|
|
|
V_BOOL(pVarResult) = MsiGetMode(This->msiHandle, V_I4(&varg0)) ? VARIANT_TRUE : VARIANT_FALSE;
|
2007-05-17 18:35:53 +02:00
|
|
|
} else if (wFlags & DISPATCH_PROPERTYPUT) {
|
2007-05-01 03:54:15 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
2012-05-01 12:39:17 +02:00
|
|
|
hr = DispGetParam(pDispParams, 1, VT_BOOL, &varg1, puArgErr);
|
2007-05-01 03:54:15 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
2007-05-17 18:35:53 +02:00
|
|
|
if ((ret = MsiSetMode(This->msiHandle, V_I4(&varg0), V_BOOL(&varg1))) != ERROR_SUCCESS)
|
2007-05-01 03:54:15 +02:00
|
|
|
{
|
|
|
|
ERR("MsiSetMode returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:15 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_SESSION_DATABASE:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-01 03:54:15 +02:00
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
2007-05-17 18:35:53 +02:00
|
|
|
if ((msiHandle = MsiGetActiveDatabase(This->msiHandle)))
|
2007-05-01 03:54:15 +02:00
|
|
|
{
|
2012-01-14 14:58:50 +01:00
|
|
|
IDispatch *dispatch;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = create_database(msiHandle, &dispatch)))
|
|
|
|
V_DISPATCH(pVarResult) = dispatch;
|
2007-05-08 00:52:53 +02:00
|
|
|
else
|
|
|
|
ERR("Failed to create Database object, hresult 0x%08x\n", hr);
|
2007-05-01 03:54:15 +02:00
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
else
|
2007-05-01 03:54:15 +02:00
|
|
|
{
|
|
|
|
ERR("MsiGetActiveDatabase failed\n");
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:15 +02:00
|
|
|
|
|
|
|
case DISPID_SESSION_DOACTION:
|
|
|
|
if (wFlags & DISPATCH_METHOD) {
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
ret = MsiDoActionW(This->msiHandle, V_BSTR(&varg0));
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case ERROR_FUNCTION_NOT_CALLED:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusNoAction;
|
|
|
|
break;
|
|
|
|
case ERROR_SUCCESS:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusSuccess;
|
|
|
|
break;
|
|
|
|
case ERROR_INSTALL_USEREXIT:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusUserExit;
|
|
|
|
break;
|
|
|
|
case ERROR_INSTALL_FAILURE:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusFailure;
|
|
|
|
break;
|
|
|
|
case ERROR_INSTALL_SUSPEND:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusSuspend;
|
|
|
|
break;
|
|
|
|
case ERROR_MORE_DATA:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusFinished;
|
|
|
|
break;
|
|
|
|
case ERROR_INVALID_HANDLE_STATE:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusWrongState;
|
|
|
|
break;
|
|
|
|
case ERROR_INVALID_DATA:
|
|
|
|
V_I4(pVarResult) = msiDoActionStatusBadActionData;
|
|
|
|
break;
|
|
|
|
default:
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg0);
|
2007-05-01 03:54:15 +02:00
|
|
|
FIXME("MsiDoAction returned unhandled value %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-01 03:54:15 +02:00
|
|
|
break;
|
|
|
|
|
2007-05-11 21:07:48 +02:00
|
|
|
case DISPID_SESSION_EVALUATECONDITION:
|
|
|
|
if (wFlags & DISPATCH_METHOD) {
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = MsiEvaluateConditionW(This->msiHandle, V_BSTR(&varg0));
|
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-11 21:07:48 +02:00
|
|
|
break;
|
|
|
|
|
2008-07-16 18:47:08 +02:00
|
|
|
case DISPID_SESSION_MESSAGE:
|
|
|
|
if(!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_DISPATCH, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) =
|
|
|
|
MsiProcessMessage(This->msiHandle, V_I4(&varg0), ((AutomationObject *)V_DISPATCH(&varg1))->msiHandle);
|
|
|
|
break;
|
|
|
|
|
2007-05-01 03:54:15 +02:00
|
|
|
case DISPID_SESSION_SETINSTALLLEVEL:
|
2007-05-11 21:08:08 +02:00
|
|
|
if (wFlags & DISPATCH_METHOD) {
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
if ((ret = MsiSetInstallLevel(This->msiHandle, V_I4(&varg0))) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("MsiSetInstallLevel returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-01 03:54:15 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-01 03:54:15 +02:00
|
|
|
break;
|
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_SESSION_FEATURECURRENTSTATE:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-01 03:54:15 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
2007-05-17 18:35:53 +02:00
|
|
|
if ((ret = MsiGetFeatureStateW(This->msiHandle, V_BSTR(&varg0), &iInstalled, &iAction)) == ERROR_SUCCESS)
|
|
|
|
V_I4(pVarResult) = iInstalled;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("MsiGetFeatureState returned %d\n", ret);
|
2007-05-01 03:54:15 +02:00
|
|
|
V_I4(pVarResult) = msiInstallStateUnknown;
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:15 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_SESSION_FEATUREREQUESTSTATE:
|
|
|
|
if (wFlags & DISPATCH_PROPERTYGET) {
|
2007-05-01 03:54:15 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
2007-05-17 18:35:53 +02:00
|
|
|
if ((ret = MsiGetFeatureStateW(This->msiHandle, V_BSTR(&varg0), &iInstalled, &iAction)) == ERROR_SUCCESS)
|
|
|
|
V_I4(pVarResult) = iAction;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("MsiGetFeatureState returned %d\n", ret);
|
2007-05-01 03:54:15 +02:00
|
|
|
V_I4(pVarResult) = msiInstallStateUnknown;
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
|
|
|
} else if (wFlags & DISPATCH_PROPERTYPUT) {
|
2007-05-01 03:54:15 +02:00
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr)) return hr;
|
2012-05-01 12:39:17 +02:00
|
|
|
hr = DispGetParam(pDispParams, 1, VT_I4, &varg1, puArgErr);
|
2007-05-01 03:54:15 +02:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
VariantClear(&varg0);
|
|
|
|
return hr;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
if ((ret = MsiSetFeatureStateW(This->msiHandle, V_BSTR(&varg0), V_I4(&varg1))) != ERROR_SUCCESS)
|
2007-05-01 03:54:15 +02:00
|
|
|
{
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg0);
|
2007-05-01 03:54:15 +02:00
|
|
|
ERR("MsiSetFeatureState returned %d\n", ret);
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
2007-05-17 18:35:53 +02:00
|
|
|
}
|
2007-05-11 21:08:08 +02:00
|
|
|
else return DISP_E_MEMBERNOTFOUND;
|
2007-05-17 18:35:53 +02:00
|
|
|
break;
|
2007-05-01 03:54:15 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
2007-05-08 14:39:38 +02:00
|
|
|
VariantClear(&varg1);
|
|
|
|
VariantClear(&varg0);
|
|
|
|
|
2007-05-01 03:54:15 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2007-05-01 03:54:24 +02:00
|
|
|
|
2007-05-10 22:40:28 +02:00
|
|
|
/* Fill the variant pointed to by pVarResult with the value & size returned by RegQueryValueEx as dictated by the
|
|
|
|
* registry value type. Used by Installer::RegistryValue. */
|
|
|
|
static void variant_from_registry_value(VARIANT *pVarResult, DWORD dwType, LPBYTE lpData, DWORD dwSize)
|
|
|
|
{
|
|
|
|
static const WCHAR szREG_BINARY[] = { '(','R','E','G','_','B','I','N','A','R','Y',')',0 };
|
2012-12-19 12:00:42 +01:00
|
|
|
static const WCHAR szREG_[] = { '(','R','E','G','_','?','?',')',0 };
|
2007-05-10 22:40:28 +02:00
|
|
|
WCHAR *szString = (WCHAR *)lpData;
|
|
|
|
LPWSTR szNewString = NULL;
|
|
|
|
DWORD dwNewSize = 0;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
switch (dwType)
|
|
|
|
{
|
|
|
|
/* Registry strings may not be null terminated so we must use SysAllocStringByteLen/Len */
|
|
|
|
case REG_MULTI_SZ: /* Multi SZ change internal null characters to newlines */
|
|
|
|
idx = (dwSize/sizeof(WCHAR))-1;
|
|
|
|
while (idx >= 0 && !szString[idx]) idx--;
|
|
|
|
for (; idx >= 0; idx--)
|
|
|
|
if (!szString[idx]) szString[idx] = '\n';
|
2011-10-06 23:29:46 +02:00
|
|
|
/* fall through */
|
2007-05-10 22:40:28 +02:00
|
|
|
case REG_SZ:
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = SysAllocStringByteLen((LPCSTR)szString, dwSize);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REG_EXPAND_SZ:
|
|
|
|
if (!(dwNewSize = ExpandEnvironmentStringsW(szString, szNewString, dwNewSize)))
|
|
|
|
ERR("ExpandEnvironmentStrings returned error %d\n", GetLastError());
|
2009-12-03 02:28:48 +01:00
|
|
|
else if (!(szNewString = msi_alloc(dwNewSize * sizeof(WCHAR))))
|
2007-05-10 22:40:28 +02:00
|
|
|
ERR("Out of memory\n");
|
|
|
|
else if (!(dwNewSize = ExpandEnvironmentStringsW(szString, szNewString, dwNewSize)))
|
|
|
|
ERR("ExpandEnvironmentStrings returned error %d\n", GetLastError());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = SysAllocStringLen(szNewString, dwNewSize);
|
|
|
|
}
|
|
|
|
msi_free(szNewString);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REG_DWORD:
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = *((DWORD *)lpData);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REG_QWORD:
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(szREG_); /* Weird string, don't know why native returns it */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REG_BINARY:
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(szREG_BINARY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REG_NONE:
|
|
|
|
V_VT(pVarResult) = VT_EMPTY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled registry value type %d\n", dwType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:01:50 +01:00
|
|
|
static HRESULT InstallerImpl_CreateRecord(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
VARIANTARG varg0;
|
|
|
|
MSIHANDLE hrec;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
|
|
|
|
|
|
|
hrec = MsiCreateRecord(V_I4(&varg0));
|
|
|
|
if (!hrec)
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
|
2013-03-13 12:47:30 +01:00
|
|
|
return create_record(hrec, &V_DISPATCH(pVarResult));
|
2009-12-11 02:01:50 +01:00
|
|
|
}
|
|
|
|
|
2009-12-11 02:01:58 +01:00
|
|
|
static HRESULT InstallerImpl_OpenPackage(AutomationObject* This,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
HRESULT hr;
|
|
|
|
MSIHANDLE hpkg;
|
|
|
|
IDispatch* dispatch;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
if (pDispParams->cArgs == 0)
|
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
|
|
|
|
if (V_VT(&pDispParams->rgvarg[pDispParams->cArgs - 1]) != VT_BSTR)
|
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
VariantInit(&varg1);
|
|
|
|
if (pDispParams->cArgs == 2)
|
|
|
|
{
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_I4, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
V_VT(&varg1) = VT_I4;
|
|
|
|
V_I4(&varg1) = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
|
|
|
|
|
|
|
ret = MsiOpenPackageExW(V_BSTR(&varg0), V_I4(&varg1), &hpkg);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
hr = DISP_E_EXCEPTION;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-01-14 12:06:17 +01:00
|
|
|
hr = create_session(hpkg, &This->IDispatch_iface, &dispatch);
|
2009-12-11 02:01:58 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
V_DISPATCH(pVarResult) = dispatch;
|
|
|
|
|
|
|
|
done:
|
|
|
|
VariantClear(&varg0);
|
|
|
|
VariantClear(&varg1);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:08 +01:00
|
|
|
static HRESULT InstallerImpl_OpenProduct(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
VARIANTARG varg0;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
FIXME("%s\n", debugstr_w(V_BSTR(&varg0)));
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
|
|
|
|
VariantClear(&varg0);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT InstallerImpl_OpenDatabase(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
HRESULT hr;
|
|
|
|
MSIHANDLE hdb;
|
|
|
|
IDispatch* dispatch;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
VariantInit(&varg1);
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_BSTR, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
|
|
|
|
|
|
|
ret = MsiOpenDatabaseW(V_BSTR(&varg0), V_BSTR(&varg1), &hdb);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
hr = DISP_E_EXCEPTION;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-01-14 14:58:50 +01:00
|
|
|
hr = create_database(hdb, &dispatch);
|
2009-12-11 02:02:08 +01:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
V_DISPATCH(pVarResult) = dispatch;
|
|
|
|
|
|
|
|
done:
|
|
|
|
VariantClear(&varg0);
|
|
|
|
VariantClear(&varg1);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:16 +01:00
|
|
|
static HRESULT InstallerImpl_SummaryInformation(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2015-08-26 08:45:53 +02:00
|
|
|
UINT ret;
|
|
|
|
HRESULT hr;
|
|
|
|
MSIHANDLE hsuminfo;
|
|
|
|
IDispatch *dispatch;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_PROPERTYGET))
|
2009-12-11 02:02:16 +01:00
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
2015-08-26 08:45:53 +02:00
|
|
|
VariantInit(&varg1);
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_I4, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2015-08-31 20:11:53 +02:00
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2015-08-26 08:45:53 +02:00
|
|
|
|
|
|
|
ret = MsiGetSummaryInformationW(0, V_BSTR(&varg0), V_I4(&varg1), &hsuminfo);
|
2015-08-31 20:11:53 +02:00
|
|
|
VariantClear(&varg0);
|
2015-08-26 08:45:53 +02:00
|
|
|
if (ret != ERROR_SUCCESS)
|
2015-08-31 20:11:53 +02:00
|
|
|
return DISP_E_EXCEPTION;
|
2015-08-26 08:45:53 +02:00
|
|
|
|
|
|
|
hr = create_summaryinfo(hsuminfo, &dispatch);
|
2015-08-31 20:11:53 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2015-08-26 08:45:53 +02:00
|
|
|
|
2015-08-31 20:11:53 +02:00
|
|
|
V_VT(pVarResult) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(pVarResult) = dispatch;
|
|
|
|
return S_OK;
|
2009-12-11 02:02:16 +01:00
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:24 +01:00
|
|
|
static HRESULT InstallerImpl_UILevel(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
VARIANTARG varg0;
|
|
|
|
INSTALLUILEVEL ui;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_PROPERTYPUT) && !(wFlags & DISPATCH_PROPERTYGET))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
if (wFlags & DISPATCH_PROPERTYPUT)
|
|
|
|
{
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
ui = MsiSetInternalUI(V_I4(&varg0), NULL);
|
|
|
|
if (ui == INSTALLUILEVEL_NOCHANGE)
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
}
|
|
|
|
else if (wFlags & DISPATCH_PROPERTYGET)
|
|
|
|
{
|
|
|
|
ui = MsiSetInternalUI(INSTALLUILEVEL_NOCHANGE, NULL);
|
|
|
|
if (ui == INSTALLUILEVEL_NOCHANGE)
|
|
|
|
return DISP_E_EXCEPTION;
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:32 +01:00
|
|
|
static HRESULT InstallerImpl_EnableLog(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:39 +01:00
|
|
|
static HRESULT InstallerImpl_InstallProduct(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
HRESULT hr;
|
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
VariantInit(&varg1);
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_BSTR, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
ret = MsiInstallProductW(V_BSTR(&varg0), V_BSTR(&varg1));
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
hr = DISP_E_EXCEPTION;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
VariantClear(&varg0);
|
|
|
|
VariantClear(&varg1);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:49 +01:00
|
|
|
static HRESULT InstallerImpl_Version(WORD wFlags,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
DLLVERSIONINFO verinfo;
|
|
|
|
WCHAR version[MAX_PATH];
|
|
|
|
|
|
|
|
static const WCHAR format[] = {
|
|
|
|
'%','d','.','%','d','.','%','d','.','%','d',0};
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_PROPERTYGET))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
verinfo.cbSize = sizeof(DLLVERSIONINFO);
|
|
|
|
hr = DllGetVersion(&verinfo);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
sprintfW(version, format, verinfo.dwMajorVersion, verinfo.dwMinorVersion,
|
|
|
|
verinfo.dwBuildNumber, verinfo.dwPlatformID);
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(version);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:32 +01:00
|
|
|
static HRESULT InstallerImpl_LastErrorRecord(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:58 +01:00
|
|
|
static HRESULT InstallerImpl_RegistryValue(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
HKEY hkey = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
UINT posValue;
|
|
|
|
DWORD type, size;
|
|
|
|
LPWSTR szString = NULL;
|
|
|
|
VARIANTARG varg0, varg1, varg2;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
VariantInit(&varg1);
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_BSTR, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Save valuePos so we can save puArgErr if we are unable to do our type
|
|
|
|
* conversions.
|
|
|
|
*/
|
|
|
|
posValue = 2;
|
|
|
|
VariantInit(&varg2);
|
|
|
|
hr = DispGetParam_CopyOnly(pDispParams, &posValue, &varg2);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (V_I4(&varg0) >= REG_INDEX_CLASSES_ROOT &&
|
|
|
|
V_I4(&varg0) <= REG_INDEX_DYN_DATA)
|
|
|
|
{
|
|
|
|
V_I4(&varg0) |= (UINT_PTR)HKEY_CLASSES_ROOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegOpenKeyW((HKEY)(UINT_PTR)V_I4(&varg0), V_BSTR(&varg1), &hkey);
|
|
|
|
|
|
|
|
/* Only VT_EMPTY case can do anything if the key doesn't exist. */
|
|
|
|
if (ret != ERROR_SUCCESS && V_VT(&varg2) != VT_EMPTY)
|
|
|
|
{
|
|
|
|
hr = DISP_E_BADINDEX;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Third parameter can be VT_EMPTY, VT_I4, or VT_BSTR */
|
|
|
|
switch (V_VT(&varg2))
|
|
|
|
{
|
|
|
|
/* Return VT_BOOL clarifying whether registry key exists or not. */
|
|
|
|
case VT_EMPTY:
|
|
|
|
V_VT(pVarResult) = VT_BOOL;
|
2015-10-21 13:59:49 +02:00
|
|
|
V_BOOL(pVarResult) = (ret == ERROR_SUCCESS) ? VARIANT_TRUE : VARIANT_FALSE;
|
2009-12-11 02:02:58 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Return the value of specified key if it exists. */
|
|
|
|
case VT_BSTR:
|
|
|
|
ret = RegQueryValueExW(hkey, V_BSTR(&varg2),
|
|
|
|
NULL, NULL, NULL, &size);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
hr = DISP_E_BADINDEX;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
szString = msi_alloc(size);
|
|
|
|
if (!szString)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RegQueryValueExW(hkey, V_BSTR(&varg2), NULL,
|
|
|
|
&type, (LPBYTE)szString, &size);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
msi_free(szString);
|
|
|
|
hr = DISP_E_BADINDEX;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
variant_from_registry_value(pVarResult, type,
|
|
|
|
(LPBYTE)szString, size);
|
|
|
|
msi_free(szString);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Try to make it into VT_I4, can use VariantChangeType for this. */
|
|
|
|
default:
|
|
|
|
hr = VariantChangeType(&varg2, &varg2, 0, VT_I4);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
if (hr == DISP_E_TYPEMISMATCH)
|
|
|
|
*puArgErr = posValue;
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Retrieve class name or maximum value name or subkey name size. */
|
|
|
|
if (!V_I4(&varg2))
|
|
|
|
ret = RegQueryInfoKeyW(hkey, NULL, &size, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
else if (V_I4(&varg2) > 0)
|
|
|
|
ret = RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, &size, NULL, NULL, NULL);
|
|
|
|
else /* V_I4(&varg2) < 0 */
|
|
|
|
ret = RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, &size,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
szString = msi_alloc(++size * sizeof(WCHAR));
|
|
|
|
if (!szString)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!V_I4(&varg2))
|
|
|
|
ret = RegQueryInfoKeyW(hkey, szString, &size,NULL, NULL, NULL,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL);
|
|
|
|
else if (V_I4(&varg2) > 0)
|
|
|
|
ret = RegEnumValueW(hkey, V_I4(&varg2)-1, szString,
|
|
|
|
&size, 0, 0, NULL, NULL);
|
|
|
|
else /* V_I4(&varg2) < 0 */
|
|
|
|
ret = RegEnumKeyW(hkey, -1 - V_I4(&varg2), szString, size);
|
|
|
|
|
|
|
|
if (ret == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(szString);
|
|
|
|
}
|
|
|
|
|
|
|
|
msi_free(szString);
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
VariantClear(&varg0);
|
|
|
|
VariantClear(&varg1);
|
|
|
|
VariantClear(&varg2);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:02:32 +01:00
|
|
|
static HRESULT InstallerImpl_Environment(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT InstallerImpl_FileAttributes(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT InstallerImpl_FileSize(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT InstallerImpl_FileVersion(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
if (!(wFlags & DISPATCH_METHOD))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
FIXME("\n");
|
|
|
|
|
|
|
|
VariantInit(pVarResult);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:03:04 +01:00
|
|
|
static HRESULT InstallerImpl_ProductState(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
VARIANTARG varg0;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_PROPERTYGET))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_I4;
|
|
|
|
V_I4(pVarResult) = MsiQueryProductStateW(V_BSTR(&varg0));
|
|
|
|
|
|
|
|
VariantClear(&varg0);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-11 02:03:10 +01:00
|
|
|
static HRESULT InstallerImpl_ProductInfo(WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
UINT ret;
|
|
|
|
HRESULT hr;
|
|
|
|
DWORD size;
|
2009-12-14 04:35:33 +01:00
|
|
|
LPWSTR str = NULL;
|
2009-12-11 02:03:10 +01:00
|
|
|
VARIANTARG varg0, varg1;
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_PROPERTYGET))
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
|
|
|
VariantInit(&varg0);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &varg0, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
VariantInit(&varg1);
|
|
|
|
hr = DispGetParam(pDispParams, 1, VT_BSTR, &varg1, puArgErr);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
V_VT(pVarResult) = VT_BSTR;
|
|
|
|
V_BSTR(pVarResult) = NULL;
|
|
|
|
|
|
|
|
ret = MsiGetProductInfoW(V_BSTR(&varg0), V_BSTR(&varg1), NULL, &size);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
hr = DISP_E_EXCEPTION;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
str = msi_alloc(++size * sizeof(WCHAR));
|
|
|
|
if (!str)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = MsiGetProductInfoW(V_BSTR(&varg0), V_BSTR(&varg1), str, &size);
|
|
|
|
if (ret != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
hr = DISP_E_EXCEPTION;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_BSTR(pVarResult) = SysAllocString(str);
|
|
|
|
hr = S_OK;
|
|
|
|
|
|
|
|
done:
|
2009-12-14 04:35:33 +01:00
|
|
|
msi_free(str);
|
2009-12-11 02:03:10 +01:00
|
|
|
VariantClear(&varg0);
|
|
|
|
VariantClear(&varg1);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
static HRESULT InstallerImpl_Products(WORD flags,
|
2009-12-11 02:03:16 +01:00
|
|
|
DISPPARAMS* pDispParams,
|
2012-01-14 23:32:01 +01:00
|
|
|
VARIANT* result,
|
2009-12-11 02:03:16 +01:00
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
IDispatch *dispatch;
|
2012-01-14 23:32:01 +01:00
|
|
|
HRESULT hr;
|
2009-12-11 02:03:16 +01:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
if (!(flags & DISPATCH_PROPERTYGET))
|
2009-12-11 02:03:16 +01:00
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
hr = create_list(NULL, &dispatch);
|
2009-12-11 02:03:16 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
V_VT(result) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(result) = dispatch;
|
2009-12-11 02:03:16 +01:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
return hr;
|
2009-12-11 02:03:16 +01:00
|
|
|
}
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
static HRESULT InstallerImpl_RelatedProducts(WORD flags,
|
2009-12-11 02:03:23 +01:00
|
|
|
DISPPARAMS* pDispParams,
|
2012-01-14 23:32:01 +01:00
|
|
|
VARIANT* result,
|
2009-12-11 02:03:23 +01:00
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
IDispatch* dispatch;
|
2012-01-14 23:32:01 +01:00
|
|
|
VARIANTARG related;
|
|
|
|
HRESULT hr;
|
2009-12-11 02:03:23 +01:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
if (!(flags & DISPATCH_PROPERTYGET))
|
2009-12-11 02:03:23 +01:00
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
VariantInit(&related);
|
|
|
|
hr = DispGetParam(pDispParams, 0, VT_BSTR, &related, puArgErr);
|
2009-12-11 02:03:23 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
hr = create_list(V_BSTR(&related), &dispatch);
|
|
|
|
VariantClear(&related);
|
2009-12-11 02:03:23 +01:00
|
|
|
|
2012-01-14 23:32:01 +01:00
|
|
|
V_VT(result) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(result) = dispatch;
|
2009-12-11 02:03:23 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
static HRESULT installer_invoke(
|
2007-05-01 03:54:24 +02:00
|
|
|
AutomationObject* This,
|
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
2007-05-11 21:07:58 +02:00
|
|
|
case DISPID_INSTALLER_CREATERECORD:
|
2009-12-11 02:01:50 +01:00
|
|
|
return InstallerImpl_CreateRecord(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2007-05-11 21:07:58 +02:00
|
|
|
|
2007-05-17 18:35:53 +02:00
|
|
|
case DISPID_INSTALLER_OPENPACKAGE:
|
2009-12-11 02:01:58 +01:00
|
|
|
return InstallerImpl_OpenPackage(This, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2007-05-01 03:54:24 +02:00
|
|
|
|
2009-12-11 02:01:43 +01:00
|
|
|
case DISPID_INSTALLER_OPENPRODUCT:
|
2009-12-11 02:02:08 +01:00
|
|
|
return InstallerImpl_OpenProduct(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
2007-06-01 04:49:52 +02:00
|
|
|
case DISPID_INSTALLER_OPENDATABASE:
|
2009-12-11 02:02:08 +01:00
|
|
|
return InstallerImpl_OpenDatabase(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2007-06-01 04:49:52 +02:00
|
|
|
|
2009-12-11 02:01:43 +01:00
|
|
|
case DISPID_INSTALLER_SUMMARYINFORMATION:
|
2009-12-11 02:02:16 +01:00
|
|
|
return InstallerImpl_SummaryInformation(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
2008-02-29 20:37:44 +01:00
|
|
|
case DISPID_INSTALLER_UILEVEL:
|
2009-12-11 02:02:24 +01:00
|
|
|
return InstallerImpl_UILevel(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2008-02-29 20:37:44 +01:00
|
|
|
|
2009-12-11 02:01:43 +01:00
|
|
|
case DISPID_INSTALLER_ENABLELOG:
|
2009-12-11 02:02:32 +01:00
|
|
|
return InstallerImpl_EnableLog(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
2007-05-14 19:14:51 +02:00
|
|
|
case DISPID_INSTALLER_INSTALLPRODUCT:
|
2009-12-11 02:02:39 +01:00
|
|
|
return InstallerImpl_InstallProduct(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
2007-05-14 19:14:51 +02:00
|
|
|
|
2007-12-02 08:35:33 +01:00
|
|
|
case DISPID_INSTALLER_VERSION:
|
2009-12-11 02:02:49 +01:00
|
|
|
return InstallerImpl_Version(wFlags, pVarResult,
|
|
|
|
pExcepInfo, puArgErr);
|
2007-12-02 08:35:33 +01:00
|
|
|
|
2009-12-11 02:01:43 +01:00
|
|
|
case DISPID_INSTALLER_LASTERRORRECORD:
|
2009-12-11 02:02:32 +01:00
|
|
|
return InstallerImpl_LastErrorRecord(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
2007-05-10 22:40:28 +02:00
|
|
|
case DISPID_INSTALLER_REGISTRYVALUE:
|
2009-12-11 02:02:58 +01:00
|
|
|
return InstallerImpl_RegistryValue(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
2007-05-10 22:40:28 +02:00
|
|
|
|
2009-12-11 02:01:43 +01:00
|
|
|
case DISPID_INSTALLER_ENVIRONMENT:
|
2009-12-11 02:02:32 +01:00
|
|
|
return InstallerImpl_Environment(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
|
|
|
case DISPID_INSTALLER_FILEATTRIBUTES:
|
2009-12-11 02:02:32 +01:00
|
|
|
return InstallerImpl_FileAttributes(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
|
|
|
case DISPID_INSTALLER_FILESIZE:
|
2009-12-11 02:02:32 +01:00
|
|
|
return InstallerImpl_FileSize(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
|
|
|
case DISPID_INSTALLER_FILEVERSION:
|
2009-12-11 02:02:32 +01:00
|
|
|
return InstallerImpl_FileVersion(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2009-12-11 02:01:43 +01:00
|
|
|
|
2007-05-08 00:50:30 +02:00
|
|
|
case DISPID_INSTALLER_PRODUCTSTATE:
|
2009-12-11 02:03:04 +01:00
|
|
|
return InstallerImpl_ProductState(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2007-05-08 00:50:30 +02:00
|
|
|
|
2007-05-17 07:42:46 +02:00
|
|
|
case DISPID_INSTALLER_PRODUCTINFO:
|
2009-12-11 02:03:10 +01:00
|
|
|
return InstallerImpl_ProductInfo(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2007-05-17 07:42:46 +02:00
|
|
|
|
2007-05-08 00:50:30 +02:00
|
|
|
case DISPID_INSTALLER_PRODUCTS:
|
2009-12-11 02:03:16 +01:00
|
|
|
return InstallerImpl_Products(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2007-05-14 19:15:13 +02:00
|
|
|
|
|
|
|
case DISPID_INSTALLER_RELATEDPRODUCTS:
|
2009-12-11 02:03:23 +01:00
|
|
|
return InstallerImpl_RelatedProducts(wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo,
|
|
|
|
puArgErr);
|
2007-05-08 00:50:30 +02:00
|
|
|
|
2009-12-11 02:03:23 +01:00
|
|
|
default:
|
2007-05-01 03:54:24 +02:00
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
}
|
2007-05-01 03:54:31 +02:00
|
|
|
|
2012-01-14 14:38:58 +01:00
|
|
|
HRESULT create_msiserver(IUnknown *outer, void **ppObj)
|
2007-05-01 03:54:31 +02:00
|
|
|
{
|
2012-01-14 14:38:58 +01:00
|
|
|
AutomationObject *installer;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p %p)\n", outer, ppObj);
|
|
|
|
|
|
|
|
if (outer)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
installer = msi_alloc(sizeof(AutomationObject));
|
|
|
|
if (!installer) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = init_automation_object(installer, 0, Installer_tid);
|
2012-01-14 14:38:58 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
msi_free(installer);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppObj = &installer->IDispatch_iface;
|
|
|
|
|
|
|
|
return hr;
|
2007-05-01 03:54:31 +02:00
|
|
|
}
|
2007-05-01 03:54:43 +02:00
|
|
|
|
2012-01-14 14:34:13 +01:00
|
|
|
HRESULT create_session(MSIHANDLE msiHandle, IDispatch *installer, IDispatch **disp)
|
2007-05-01 03:54:43 +02:00
|
|
|
{
|
2012-01-14 14:34:13 +01:00
|
|
|
SessionObject *session;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
session = msi_alloc(sizeof(SessionObject));
|
|
|
|
if (!session) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = init_automation_object(&session->autoobj, msiHandle, Session_tid);
|
2012-01-14 14:34:13 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
msi_free(session);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
session->installer = installer;
|
|
|
|
*disp = &session->autoobj.IDispatch_iface;
|
|
|
|
|
2007-05-05 06:18:19 +02:00
|
|
|
return hr;
|
2007-05-01 03:54:43 +02:00
|
|
|
}
|
2012-01-17 00:12:30 +01:00
|
|
|
|
|
|
|
static HRESULT create_database(MSIHANDLE msiHandle, IDispatch **dispatch)
|
|
|
|
{
|
|
|
|
AutomationObject *database;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%d %p)\n", msiHandle, dispatch);
|
|
|
|
|
|
|
|
database = msi_alloc(sizeof(AutomationObject));
|
|
|
|
if (!database) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = init_automation_object(database, msiHandle, Database_tid);
|
2012-01-17 00:12:30 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
msi_free(database);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*dispatch = &database->IDispatch_iface;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT create_view(MSIHANDLE msiHandle, IDispatch **dispatch)
|
|
|
|
{
|
|
|
|
AutomationObject *view;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%d %p)\n", msiHandle, dispatch);
|
|
|
|
|
|
|
|
view = msi_alloc(sizeof(AutomationObject));
|
|
|
|
if (!view) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = init_automation_object(view, msiHandle, View_tid);
|
2012-01-17 00:12:30 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
msi_free(view);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*dispatch = &view->IDispatch_iface;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT create_summaryinfo(MSIHANDLE msiHandle, IDispatch **disp)
|
|
|
|
{
|
|
|
|
AutomationObject *info;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
info = msi_alloc(sizeof(*info));
|
|
|
|
if (!info) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-14 06:26:14 +01:00
|
|
|
hr = init_automation_object(info, msiHandle, SummaryInfo_tid);
|
2012-01-17 00:12:30 +01:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
msi_free(info);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*disp = &info->IDispatch_iface;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|