msi: Implement SummaryInfo::Property get.

This commit is contained in:
James Hawkins 2007-05-31 19:52:05 -07:00 committed by Alexandre Julliard
parent 7a289624cf
commit f083b3c038
4 changed files with 144 additions and 1 deletions

View File

@ -730,6 +730,114 @@ HRESULT WINAPI DispGetParam_CopyOnly(
&pdispparams->rgvarg[pos]);
}
static HRESULT WINAPI SummaryInfoImpl_Invoke(
AutomationObject* This,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pDispParams,
VARIANT* pVarResult,
EXCEPINFO* pExcepInfo,
UINT* puArgErr)
{
UINT ret;
VARIANTARG varg0;
HRESULT hr;
VariantInit(&varg0);
switch (dispIdMember)
{
case DISPID_SUMMARYINFO_PROPERTY:
if (wFlags & DISPATCH_PROPERTYGET)
{
UINT type;
INT value;
INT pid;
static WCHAR szEmpty[] = {0};
VariantClear(pVarResult);
hr = DispGetParam(pDispParams, 0, VT_I4, &varg0, puArgErr);
if (FAILED(hr)) return hr;
pid = V_I4(&varg0);
if (pid == PID_CODEPAGE || (pid >= PID_PAGECOUNT && pid <= PID_CHARCOUNT) || PID_SECURITY)
{
ret = MsiSummaryInfoGetPropertyW(This->msiHandle, pid, &type, &value,
NULL, NULL, NULL);
if (ret != ERROR_SUCCESS)
return DISP_E_EXCEPTION;
if (pid == PID_CODEPAGE)
{
V_VT(pVarResult) = VT_I2;
V_I2(pVarResult) = value;
}
else
{
V_VT(pVarResult) = VT_I4;
V_I4(pVarResult) = value;
}
}
else if ((pid >= PID_TITLE && pid <= PID_REVNUMBER) || pid == PID_APPNAME)
{
LPWSTR str;
DWORD size = 0;
ret = MsiSummaryInfoGetPropertyW(This->msiHandle, pid, &type, NULL,
NULL, szEmpty, &size);
if (ret != ERROR_MORE_DATA)
return DISP_E_EXCEPTION;
str = msi_alloc(++size * sizeof(WCHAR));
if (!str)
return DISP_E_EXCEPTION;
ret = MsiSummaryInfoGetPropertyW(This->msiHandle, pid, &type, NULL,
NULL, str, &size);
if (ret != ERROR_SUCCESS)
{
msi_free(str);
return DISP_E_EXCEPTION;
}
V_VT(pVarResult) = VT_BSTR;
V_BSTR(pVarResult) = SysAllocString(str);
msi_free(str);
}
else if (pid >= PID_EDITTIME && pid <= PID_LASTSAVE_DTM)
{
FILETIME ft;
SYSTEMTIME st;
DATE date;
ret = MsiSummaryInfoGetPropertyW(This->msiHandle, pid, &type, &value,
&ft, NULL, NULL);
if (ret != ERROR_SUCCESS)
return DISP_E_EXCEPTION;
FileTimeToSystemTime(&ft, &st);
SystemTimeToVariantTime(&st, &date);
V_VT(pVarResult) = VT_DATE;
V_DATE(pVarResult) = date;
}
}
else return DISP_E_MEMBERNOTFOUND;
break;
default:
ERR("Member not found: %d\n", dispIdMember);
return DISP_E_MEMBERNOTFOUND;
}
VariantClear(&varg0);
return S_OK;
}
static HRESULT WINAPI RecordImpl_Invoke(
AutomationObject* This,
DISPID dispIdMember,
@ -1010,6 +1118,34 @@ static HRESULT WINAPI DatabaseImpl_Invoke(
switch (dispIdMember)
{
case DISPID_DATABASE_SUMMARYINFORMATION:
if (wFlags & DISPATCH_METHOD)
{
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)
{
hr = create_automation_object(msiHandle, NULL, (LPVOID *)&pDispatch, &DIID_SummaryInfo, SummaryInfoImpl_Invoke, NULL, 0);
if (SUCCEEDED(hr))
{
IDispatch_AddRef(pDispatch);
V_DISPATCH(pVarResult) = pDispatch;
}
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;
case DISPID_DATABASE_OPENVIEW:
if (wFlags & DISPATCH_METHOD)
{

View File

@ -146,6 +146,8 @@ library WindowsInstaller
{
properties:
methods:
[id(DISPID_SUMMARYINFO_PROPERTY), propget]
VARIANT Property([in] long Pid);
}
typedef enum {
@ -188,6 +190,8 @@ library WindowsInstaller
methods:
[id(DISPID_DATABASE_OPENVIEW)]
View* OpenView([in] BSTR Sql);
[id(DISPID_DATABASE_SUMMARYINFORMATION)]
SummaryInfo *SummaryInformation([in, optional, defaultvalue(0)] long UpdateCount);
}
typedef enum {

View File

@ -39,6 +39,7 @@
#define DISPID_VIEW_MODIFY 3
#define DISPID_VIEW_CLOSE 4
#define DISPID_DATABASE_SUMMARYINFORMATION 2
#define DISPID_DATABASE_OPENVIEW 3
#define DISPID_SESSION_INSTALLER 1
@ -51,3 +52,5 @@
#define DISPID_SESSION_FEATURECURRENTSTATE 13
#define DISPID_SESSION_FEATUREREQUESTSTATE 14
#define DISPID_SESSION_SETINSTALLLEVEL 19
#define DISPID_SUMMARYINFO_PROPERTY 1

View File

@ -229,7 +229,7 @@ enum msidbServiceControlEvent
#define PID_TEMPLATE 7
#define PID_LASTAUTHOR 8
#define PID_REVNUMBER 9
#define PID_EDITTINE 10
#define PID_EDITTIME 10
#define PID_LASTPRINTED 11
#define PID_CREATE_DTM 12
#define PID_LASTSAVE_DTM 13