msi: automation: Store parent Installer object in Session.
This commit is contained in:
parent
4a5a90b04a
commit
8ba0b3c7b9
|
@ -61,6 +61,9 @@ interface AutomationObject {
|
|||
/* The MSI handle of the current object */
|
||||
MSIHANDLE msiHandle;
|
||||
|
||||
/* The parent Installer object (only used in the Session object) */
|
||||
IDispatch *pInstaller;
|
||||
|
||||
/* A function that is called from AutomationObject::Invoke, specific to this type of object. */
|
||||
HRESULT (STDMETHODCALLTYPE *funcInvoke)(
|
||||
AutomationObject* This,
|
||||
|
@ -134,6 +137,7 @@ HRESULT create_automation_object(MSIHANDLE msiHandle, IUnknown *pUnkOuter, LPVOI
|
|||
object->msiHandle = msiHandle;
|
||||
object->clsid = (LPCLSID)clsid;
|
||||
object->funcInvoke = funcInvoke;
|
||||
object->pInstaller = NULL;
|
||||
|
||||
/* Load our TypeInfo so we don't have to process GetIDsOfNames */
|
||||
object->iTypeInfo = NULL;
|
||||
|
@ -894,7 +898,7 @@ static HRESULT WINAPI InstallerImpl_Invoke(
|
|||
V_VT(pVarResult) = VT_DISPATCH;
|
||||
if ((ret = MsiOpenPackageExW(V_BSTR(&varg0), V_I4(&varg1), &msiHandle)) == ERROR_SUCCESS)
|
||||
{
|
||||
if (SUCCEEDED(create_automation_object(msiHandle, NULL, (LPVOID*)&pDispatch, &DIID_Session, SessionImpl_Invoke)))
|
||||
if (SUCCEEDED(create_session(msiHandle, (IDispatch *)This, &pDispatch)))
|
||||
{
|
||||
IDispatch_AddRef(pDispatch);
|
||||
V_DISPATCH(pVarResult) = pDispatch;
|
||||
|
@ -922,7 +926,10 @@ HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj)
|
|||
}
|
||||
|
||||
/* Wrapper around create_automation_object to create a session object. */
|
||||
HRESULT create_session(MSIHANDLE msiHandle, IDispatch **pDispatch)
|
||||
HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch)
|
||||
{
|
||||
return create_automation_object(msiHandle, NULL, (LPVOID)pDispatch, &DIID_Session, SessionImpl_Invoke);
|
||||
HRESULT hr = create_automation_object(msiHandle, NULL, (LPVOID)pDispatch, &DIID_Session, SessionImpl_Invoke);
|
||||
if (SUCCEEDED(hr) && pDispatch && *pDispatch)
|
||||
((AutomationObject *)*pDispatch)->pInstaller = (IDispatch *)pInstaller;
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -793,7 +793,7 @@ extern VOID ControlEvent_UnSubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
|
|||
|
||||
/* OLE automation */
|
||||
extern HRESULT create_msiserver(IUnknown *pOuter, LPVOID *ppObj);
|
||||
extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch **pDispatch);
|
||||
extern HRESULT create_session(MSIHANDLE msiHandle, IDispatch *pInstaller, IDispatch **pDispatch);
|
||||
extern HRESULT load_type_info(IDispatch *iface, ITypeInfo **pptinfo, REFIID clsid, LCID lcid);
|
||||
|
||||
/* Scripting */
|
||||
|
|
|
@ -46,6 +46,7 @@ static const WCHAR szSession[] = {'S','e','s','s','i','o','n',0};
|
|||
|
||||
typedef struct {
|
||||
IActiveScriptSite lpVtbl;
|
||||
IDispatch *pInstaller;
|
||||
IDispatch *pSession;
|
||||
LONG ref;
|
||||
} MsiActiveScriptSite;
|
||||
|
@ -65,6 +66,7 @@ static HRESULT create_ActiveScriptSite(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|||
|
||||
object->lpVtbl.lpVtbl = &ASS_Vtbl;
|
||||
object->ref = 1;
|
||||
object->pInstaller = NULL;
|
||||
object->pSession = NULL;
|
||||
|
||||
*ppObj = object;
|
||||
|
@ -97,8 +99,13 @@ DWORD call_script(MSIHANDLE hPackage, INT type, LPCWSTR script, LPCWSTR function
|
|||
hr = create_ActiveScriptSite(NULL, (void **)&pActiveScriptSite);
|
||||
if (hr != S_OK) goto done;
|
||||
|
||||
/* Create an installer object */
|
||||
hr = create_msiserver(NULL, (LPVOID *)&pActiveScriptSite->pInstaller);
|
||||
if (hr != S_OK) goto done;
|
||||
IUnknown_AddRef((IUnknown *)pActiveScriptSite->pInstaller);
|
||||
|
||||
/* Create a session object */
|
||||
hr = create_session(hPackage, &pActiveScriptSite->pSession);
|
||||
hr = create_session(hPackage, pActiveScriptSite->pInstaller, &pActiveScriptSite->pSession);
|
||||
if (hr != S_OK) goto done;
|
||||
IUnknown_AddRef((IUnknown *)pActiveScriptSite->pSession);
|
||||
|
||||
|
@ -181,6 +188,8 @@ done:
|
|||
if (pActiveScript) IActiveScriptSite_Release(pActiveScript);
|
||||
if (pActiveScriptSite &&
|
||||
pActiveScriptSite->pSession) IUnknown_Release((IUnknown *)pActiveScriptSite->pSession);
|
||||
if (pActiveScriptSite &&
|
||||
pActiveScriptSite->pInstaller) IUnknown_Release((IUnknown *)pActiveScriptSite->pInstaller);
|
||||
if (pActiveScriptSite) IUnknown_Release((IUnknown *)pActiveScriptSite);
|
||||
|
||||
CoUninitialize(); /* must call even if CoInitialize failed */
|
||||
|
|
Loading…
Reference in New Issue