Partial implementation of the Microsoft Installer (msi.dll).
[wine/hacks.git] / dlls / msi / suminfo.c
blob3e54818f6c3f6b72afa17ae417f1c969b0406c57
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002 Mike McCormack for Codeweavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define NONAMELESSUNION
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winreg.h"
26 #include "shlwapi.h"
27 #include "wine/debug.h"
28 #include "msi.h"
29 #include "msiquery.h"
30 #include "msipriv.h"
31 #include "objidl.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msi);
35 const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
36 'I','n','f','o','r','m','a','t','i','o','n',0 };
38 static void MSI_CloseSummaryInfo( VOID *arg )
40 MSISUMMARYINFO *suminfo = (MSISUMMARYINFO *) arg;
41 IPropertyStorage_Release( suminfo->propstg );
44 UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase,
45 LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
47 LPWSTR szwDatabase = NULL;
48 UINT ret;
50 TRACE("%ld %s %d %p\n", hDatabase, debugstr_a(szDatabase),
51 uiUpdateCount, phSummaryInfo);
53 if( szDatabase )
55 szwDatabase = HEAP_strdupAtoW( GetProcessHeap(), 0, szDatabase );
56 if( !szwDatabase )
57 return ERROR_FUNCTION_FAILED;
60 ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, phSummaryInfo);
62 if( szwDatabase )
63 HeapFree( GetProcessHeap(), 0, szwDatabase );
65 return ret;
68 UINT WINAPI MsiGetSummaryInformationW(MSIHANDLE hDatabase,
69 LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
71 HRESULT r;
72 MSIHANDLE handle, hdb = hDatabase;
73 MSISUMMARYINFO *suminfo;
74 MSIDATABASE *db;
75 UINT ret = ERROR_SUCCESS;
76 IPropertySetStorage *psstg = NULL;
77 IPropertyStorage *ps = NULL;
78 DWORD grfMode;
80 TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
81 uiUpdateCount, phSummaryInfo);
83 if( !phSummaryInfo )
84 return ERROR_INVALID_PARAMETER;
86 if( szDatabase )
88 UINT res;
90 res = MsiOpenDatabaseW(szDatabase, NULL, &hdb);
91 if( res != ERROR_SUCCESS )
92 return res;
95 db = msihandle2msiinfo(hdb, MSIHANDLETYPE_DATABASE);
96 if( !db )
97 return ERROR_INVALID_PARAMETER;
99 r = IStorage_QueryInterface( db->storage,
100 &IID_IPropertySetStorage, (LPVOID)&psstg);
101 if( FAILED( r ) )
103 ERR("IStorage -> IPropertySetStorage failed\n");
104 return ERROR_FUNCTION_FAILED;
106 ERR("storage = %p propertysetstorage = %p\n", db->storage, psstg);
108 grfMode = STGM_READ | STGM_SHARE_EXCLUSIVE;
109 r = IPropertySetStorage_Open( psstg, &FMTID_SummaryInformation, grfMode, &ps );
110 if( FAILED( r ) )
112 ERR("failed to get IPropertyStorage r=%08lx\n",r);
113 ret = ERROR_FUNCTION_FAILED;
114 goto end;
117 handle = alloc_msihandle( MSIHANDLETYPE_SUMMARYINFO,
118 sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo );
119 if( !handle )
121 ret = ERROR_FUNCTION_FAILED;
122 goto end;
125 suminfo = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
126 if( !suminfo )
128 ret = ERROR_FUNCTION_FAILED;
129 goto end;
132 IPropertyStorage_AddRef(ps);
133 suminfo->propstg = ps;
134 *phSummaryInfo = handle;
136 end:
137 if( ps )
138 IPropertyStorage_Release(ps);
139 if( psstg )
140 IPropertySetStorage_Release(psstg);
141 if( !hDatabase )
142 MsiCloseHandle( hdb );
144 return ret;
147 UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
149 MSISUMMARYINFO *suminfo;
151 FIXME("%ld %p\n",hSummaryInfo, pCount);
153 suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
154 if( !suminfo )
155 return ERROR_INVALID_HANDLE;
157 return ERROR_CALL_NOT_IMPLEMENTED;
160 UINT WINAPI MsiSummaryInfoGetPropertyA(
161 MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
162 FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)
164 MSISUMMARYINFO *suminfo;
165 HRESULT r;
166 PROPSPEC spec;
167 PROPVARIANT var;
169 TRACE("%ld %d %p %p %p %p %p\n",
170 hSummaryInfo, uiProperty, puiDataType, piValue,
171 pftValue, szValueBuf, pcchValueBuf);
173 suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
174 if( !suminfo )
175 return ERROR_INVALID_HANDLE;
177 spec.ulKind = PRSPEC_PROPID;
178 spec.DUMMYUNIONNAME.propid = uiProperty;
180 r = IPropertyStorage_ReadMultiple( suminfo->propstg, 1, &spec, &var);
181 if( FAILED(r) )
182 return ERROR_FUNCTION_FAILED;
184 if( puiDataType )
185 *puiDataType = var.vt;
187 switch( var.vt )
189 case VT_I4:
190 if( piValue )
191 *piValue = var.DUMMYUNIONNAME.lVal;
192 break;
193 case VT_LPSTR:
194 if( pcchValueBuf && szValueBuf )
196 lstrcpynA(szValueBuf, var.DUMMYUNIONNAME.pszVal, *pcchValueBuf );
197 *pcchValueBuf = lstrlenA( var.DUMMYUNIONNAME.pszVal );
199 break;
200 case VT_FILETIME:
201 if( pftValue )
202 memcpy(pftValue, &var.DUMMYUNIONNAME.filetime, sizeof (FILETIME) );
203 break;
204 case VT_EMPTY:
205 break;
206 default:
207 FIXME("Unknown property variant type\n");
208 break;
211 return ERROR_SUCCESS;
214 UINT WINAPI MsiSummaryInfoGetPropertyW(
215 MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
216 FILETIME *pftValue, LPWSTR szValueBuf, DWORD *pcchValueBuf)
218 FIXME("%ld %d %p %p %p %p %p\n",
219 hSummaryInfo, uiProperty, puiDataType, piValue,
220 pftValue, szValueBuf, pcchValueBuf);
222 return ERROR_CALL_NOT_IMPLEMENTED;