2003-08-13 03:27:48 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
2003-09-08 21:38:45 +02:00
|
|
|
* Copyright 2002 Mike McCormack for CodeWeavers
|
2003-08-13 03:27:48 +02:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
2003-09-27 04:24:31 +02:00
|
|
|
#include "winnls.h"
|
2003-08-13 03:27:48 +02:00
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "msi.h"
|
|
|
|
#include "msiquery.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "objidl.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
|
2003-08-13 03:27:48 +02:00
|
|
|
'I','n','f','o','r','m','a','t','i','o','n',0 };
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
static void MSI_CloseSummaryInfo( MSIOBJECTHDR *arg )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
MSISUMMARYINFO *suminfo = (MSISUMMARYINFO *) arg;
|
|
|
|
IPropertyStorage_Release( suminfo->propstg );
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase,
|
|
|
|
LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
|
|
|
|
{
|
|
|
|
LPWSTR szwDatabase = NULL;
|
|
|
|
UINT ret;
|
|
|
|
|
|
|
|
TRACE("%ld %s %d %p\n", hDatabase, debugstr_a(szDatabase),
|
|
|
|
uiUpdateCount, phSummaryInfo);
|
|
|
|
|
|
|
|
if( szDatabase )
|
|
|
|
{
|
2003-09-27 04:24:31 +02:00
|
|
|
UINT len = MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, NULL, 0 );
|
|
|
|
szwDatabase = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
|
2003-08-13 03:27:48 +02:00
|
|
|
if( !szwDatabase )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2003-09-27 04:24:31 +02:00
|
|
|
MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, szwDatabase, len );
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, phSummaryInfo);
|
|
|
|
|
|
|
|
if( szwDatabase )
|
|
|
|
HeapFree( GetProcessHeap(), 0, szwDatabase );
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiGetSummaryInformationW(MSIHANDLE hDatabase,
|
|
|
|
LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
|
|
|
|
{
|
|
|
|
HRESULT r;
|
2004-07-10 00:25:34 +02:00
|
|
|
MSIHANDLE handle;
|
2003-08-13 03:27:48 +02:00
|
|
|
MSISUMMARYINFO *suminfo;
|
|
|
|
MSIDATABASE *db;
|
|
|
|
UINT ret = ERROR_SUCCESS;
|
|
|
|
IPropertySetStorage *psstg = NULL;
|
|
|
|
IPropertyStorage *ps = NULL;
|
|
|
|
DWORD grfMode;
|
|
|
|
|
|
|
|
TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
|
|
|
|
uiUpdateCount, phSummaryInfo);
|
|
|
|
|
|
|
|
if( !phSummaryInfo )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if( szDatabase )
|
|
|
|
{
|
|
|
|
UINT res;
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
res = MSI_OpenDatabaseW(szDatabase, NULL, &db);
|
2003-08-13 03:27:48 +02:00
|
|
|
if( res != ERROR_SUCCESS )
|
|
|
|
return res;
|
|
|
|
}
|
2004-07-10 00:25:34 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
db = msihandle2msiinfo(hDatabase, MSIHANDLETYPE_DATABASE);
|
|
|
|
if( !db )
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
r = IStorage_QueryInterface( db->storage,
|
|
|
|
&IID_IPropertySetStorage, (LPVOID)&psstg);
|
|
|
|
if( FAILED( r ) )
|
|
|
|
{
|
|
|
|
ERR("IStorage -> IPropertySetStorage failed\n");
|
2004-07-10 00:25:34 +02:00
|
|
|
if (db)
|
|
|
|
msiobj_release(&db->hdr);
|
2003-08-13 03:27:48 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
ERR("storage = %p propertysetstorage = %p\n", db->storage, psstg);
|
|
|
|
|
|
|
|
grfMode = STGM_READ | STGM_SHARE_EXCLUSIVE;
|
|
|
|
r = IPropertySetStorage_Open( psstg, &FMTID_SummaryInformation, grfMode, &ps );
|
|
|
|
if( FAILED( r ) )
|
|
|
|
{
|
|
|
|
ERR("failed to get IPropertyStorage r=%08lx\n",r);
|
|
|
|
ret = ERROR_FUNCTION_FAILED;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2004-07-10 00:25:34 +02:00
|
|
|
suminfo = alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO,
|
|
|
|
sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo );
|
|
|
|
if( !suminfo )
|
2003-08-13 03:27:48 +02:00
|
|
|
{
|
|
|
|
ret = ERROR_FUNCTION_FAILED;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
IPropertyStorage_AddRef(ps);
|
|
|
|
suminfo->propstg = ps;
|
2004-07-10 00:25:34 +02:00
|
|
|
handle = alloc_msihandle( &suminfo->hdr );
|
|
|
|
if( handle )
|
2003-08-13 03:27:48 +02:00
|
|
|
*phSummaryInfo = handle;
|
2004-07-10 00:25:34 +02:00
|
|
|
else
|
|
|
|
ret = ERROR_FUNCTION_FAILED;
|
|
|
|
msiobj_release( &suminfo->hdr );
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
end:
|
|
|
|
if( ps )
|
|
|
|
IPropertyStorage_Release(ps);
|
|
|
|
if( psstg )
|
|
|
|
IPropertySetStorage_Release(psstg);
|
2004-07-10 00:25:34 +02:00
|
|
|
if (db)
|
|
|
|
msiobj_release(&db->hdr);
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
|
|
|
|
{
|
|
|
|
MSISUMMARYINFO *suminfo;
|
|
|
|
|
|
|
|
FIXME("%ld %p\n",hSummaryInfo, pCount);
|
|
|
|
|
|
|
|
suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
|
|
|
|
if( !suminfo )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiSummaryInfoGetPropertyA(
|
|
|
|
MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
|
|
|
|
FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)
|
|
|
|
{
|
|
|
|
MSISUMMARYINFO *suminfo;
|
|
|
|
HRESULT r;
|
|
|
|
PROPSPEC spec;
|
|
|
|
PROPVARIANT var;
|
|
|
|
|
|
|
|
TRACE("%ld %d %p %p %p %p %p\n",
|
|
|
|
hSummaryInfo, uiProperty, puiDataType, piValue,
|
|
|
|
pftValue, szValueBuf, pcchValueBuf);
|
|
|
|
|
|
|
|
suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
|
|
|
|
if( !suminfo )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
2004-01-07 01:47:35 +01:00
|
|
|
spec.u.propid = uiProperty;
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
r = IPropertyStorage_ReadMultiple( suminfo->propstg, 1, &spec, &var);
|
|
|
|
if( FAILED(r) )
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
|
|
|
|
if( puiDataType )
|
|
|
|
*puiDataType = var.vt;
|
|
|
|
|
|
|
|
switch( var.vt )
|
|
|
|
{
|
|
|
|
case VT_I4:
|
|
|
|
if( piValue )
|
2004-01-07 01:47:35 +01:00
|
|
|
*piValue = var.u.lVal;
|
2003-08-13 03:27:48 +02:00
|
|
|
break;
|
|
|
|
case VT_LPSTR:
|
|
|
|
if( pcchValueBuf && szValueBuf )
|
|
|
|
{
|
2004-01-07 01:47:35 +01:00
|
|
|
lstrcpynA(szValueBuf, var.u.pszVal, *pcchValueBuf );
|
|
|
|
*pcchValueBuf = lstrlenA( var.u.pszVal );
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VT_FILETIME:
|
|
|
|
if( pftValue )
|
2004-01-07 01:47:35 +01:00
|
|
|
memcpy(pftValue, &var.u.filetime, sizeof (FILETIME) );
|
2003-08-13 03:27:48 +02:00
|
|
|
break;
|
|
|
|
case VT_EMPTY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unknown property variant type\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiSummaryInfoGetPropertyW(
|
|
|
|
MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
|
|
|
|
FILETIME *pftValue, LPWSTR szValueBuf, DWORD *pcchValueBuf)
|
|
|
|
{
|
|
|
|
FIXME("%ld %d %p %p %p %p %p\n",
|
|
|
|
hSummaryInfo, uiProperty, puiDataType, piValue,
|
|
|
|
pftValue, szValueBuf, pcchValueBuf);
|
|
|
|
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|