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);
|
|
|
|
|
2005-01-20 11:36:35 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, szwDatabase );
|
2003-08-13 03:27:48 +02:00
|
|
|
|
|
|
|
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");
|
2005-02-16 17:25:09 +01:00
|
|
|
ret = ERROR_FUNCTION_FAILED;
|
|
|
|
goto end;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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 )
|
2005-02-16 17:25:09 +01: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);
|
2005-02-16 17:25:09 +01:00
|
|
|
if( db )
|
2004-07-10 00:25:34 +02:00
|
|
|
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)
|
|
|
|
{
|
2005-01-24 12:24:35 +01:00
|
|
|
MSISUMMARYINFO *suminfo;
|
|
|
|
HRESULT r;
|
|
|
|
PROPSPEC spec;
|
|
|
|
PROPVARIANT var;
|
|
|
|
|
|
|
|
TRACE("%ld %d %p %p %p %p %p\n",
|
2003-08-13 03:27:48 +02:00
|
|
|
hSummaryInfo, uiProperty, puiDataType, piValue,
|
|
|
|
pftValue, szValueBuf, pcchValueBuf);
|
2005-01-24 12:24:35 +01:00
|
|
|
|
|
|
|
suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
|
|
|
|
if( !suminfo )
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
spec.u.propid = uiProperty;
|
|
|
|
|
|
|
|
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 )
|
|
|
|
*piValue = var.u.lVal;
|
|
|
|
break;
|
|
|
|
case VT_LPSTR:
|
|
|
|
if( pcchValueBuf && szValueBuf )
|
|
|
|
{
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, var.u.pszVal, -1, szValueBuf,
|
|
|
|
*pcchValueBuf );
|
|
|
|
*pcchValueBuf = lstrlenA( var.u.pszVal );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VT_FILETIME:
|
|
|
|
if( pftValue )
|
|
|
|
memcpy(pftValue, &var.u.filetime, sizeof (FILETIME) );
|
|
|
|
break;
|
|
|
|
case VT_EMPTY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unknown property variant type\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2003-08-13 03:27:48 +02:00
|
|
|
}
|
2005-02-01 15:21:03 +01:00
|
|
|
|
|
|
|
UINT WINAPI MsiSummaryInfoSetPropertyA( MSIHANDLE hSummaryInfo, UINT uiProperty,
|
|
|
|
UINT uiDataType, INT iValue,
|
2005-02-16 17:25:09 +01:00
|
|
|
FILETIME* pftValue, LPSTR szValue )
|
2005-02-01 15:21:03 +01:00
|
|
|
{
|
2005-02-16 17:25:09 +01:00
|
|
|
FIXME("%ld %u %u %i %p %s\n", hSummaryInfo, uiProperty,
|
|
|
|
uiDataType, iValue, pftValue, debugstr_a(szValue) );
|
2005-02-01 15:21:03 +01:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
UINT WINAPI MsiSummaryInfoSetPropertyW( MSIHANDLE hSummaryInfo, UINT uiProperty,
|
|
|
|
UINT uiDataType, INT iValue,
|
2005-02-16 17:25:09 +01:00
|
|
|
FILETIME* pftValue, LPWSTR szValue )
|
2005-02-01 15:21:03 +01:00
|
|
|
{
|
2005-02-16 17:25:09 +01:00
|
|
|
FIXME("%ld %u %u %i %p %s\n", hSummaryInfo, uiProperty,
|
|
|
|
uiDataType, iValue, pftValue, debugstr_w(szValue) );
|
2005-02-01 15:21:03 +01:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2005-02-16 17:25:09 +01:00
|
|
|
UINT WINAPI MsiSummaryInfoPersist( MSIHANDLE hSummaryInfo )
|
2005-02-01 15:21:03 +01:00
|
|
|
{
|
2005-02-16 17:25:09 +01:00
|
|
|
FIXME("%ld\n", hSummaryInfo );
|
2005-02-01 15:21:03 +01:00
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|