Fixed header dependencies to be fully compatible with the Windows
[wine/multimedia.git] / dlls / msi / suminfo.c
blob4a9792f43f6c7c8922ff77aa32ab82ad364d2278
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 <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winreg.h"
28 #include "shlwapi.h"
29 #include "wine/debug.h"
30 #include "msi.h"
31 #include "msiquery.h"
32 #include "msipriv.h"
33 #include "objidl.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(msi);
37 const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
38 'I','n','f','o','r','m','a','t','i','o','n',0 };
40 static void MSI_CloseSummaryInfo( VOID *arg )
42 MSISUMMARYINFO *suminfo = (MSISUMMARYINFO *) arg;
43 IPropertyStorage_Release( suminfo->propstg );
46 UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase,
47 LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
49 LPWSTR szwDatabase = NULL;
50 UINT ret;
52 TRACE("%ld %s %d %p\n", hDatabase, debugstr_a(szDatabase),
53 uiUpdateCount, phSummaryInfo);
55 if( szDatabase )
57 szwDatabase = HEAP_strdupAtoW( GetProcessHeap(), 0, szDatabase );
58 if( !szwDatabase )
59 return ERROR_FUNCTION_FAILED;
62 ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, phSummaryInfo);
64 if( szwDatabase )
65 HeapFree( GetProcessHeap(), 0, szwDatabase );
67 return ret;
70 UINT WINAPI MsiGetSummaryInformationW(MSIHANDLE hDatabase,
71 LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
73 HRESULT r;
74 MSIHANDLE handle, hdb = hDatabase;
75 MSISUMMARYINFO *suminfo;
76 MSIDATABASE *db;
77 UINT ret = ERROR_SUCCESS;
78 IPropertySetStorage *psstg = NULL;
79 IPropertyStorage *ps = NULL;
80 DWORD grfMode;
82 TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
83 uiUpdateCount, phSummaryInfo);
85 if( !phSummaryInfo )
86 return ERROR_INVALID_PARAMETER;
88 if( szDatabase )
90 UINT res;
92 res = MsiOpenDatabaseW(szDatabase, NULL, &hdb);
93 if( res != ERROR_SUCCESS )
94 return res;
97 db = msihandle2msiinfo(hdb, MSIHANDLETYPE_DATABASE);
98 if( !db )
99 return ERROR_INVALID_PARAMETER;
101 r = IStorage_QueryInterface( db->storage,
102 &IID_IPropertySetStorage, (LPVOID)&psstg);
103 if( FAILED( r ) )
105 ERR("IStorage -> IPropertySetStorage failed\n");
106 return ERROR_FUNCTION_FAILED;
108 ERR("storage = %p propertysetstorage = %p\n", db->storage, psstg);
110 grfMode = STGM_READ | STGM_SHARE_EXCLUSIVE;
111 r = IPropertySetStorage_Open( psstg, &FMTID_SummaryInformation, grfMode, &ps );
112 if( FAILED( r ) )
114 ERR("failed to get IPropertyStorage r=%08lx\n",r);
115 ret = ERROR_FUNCTION_FAILED;
116 goto end;
119 handle = alloc_msihandle( MSIHANDLETYPE_SUMMARYINFO,
120 sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo );
121 if( !handle )
123 ret = ERROR_FUNCTION_FAILED;
124 goto end;
127 suminfo = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
128 if( !suminfo )
130 ret = ERROR_FUNCTION_FAILED;
131 goto end;
134 IPropertyStorage_AddRef(ps);
135 suminfo->propstg = ps;
136 *phSummaryInfo = handle;
138 end:
139 if( ps )
140 IPropertyStorage_Release(ps);
141 if( psstg )
142 IPropertySetStorage_Release(psstg);
143 if( !hDatabase )
144 MsiCloseHandle( hdb );
146 return ret;
149 UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
151 MSISUMMARYINFO *suminfo;
153 FIXME("%ld %p\n",hSummaryInfo, pCount);
155 suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
156 if( !suminfo )
157 return ERROR_INVALID_HANDLE;
159 return ERROR_CALL_NOT_IMPLEMENTED;
162 UINT WINAPI MsiSummaryInfoGetPropertyA(
163 MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
164 FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)
166 MSISUMMARYINFO *suminfo;
167 HRESULT r;
168 PROPSPEC spec;
169 PROPVARIANT var;
171 TRACE("%ld %d %p %p %p %p %p\n",
172 hSummaryInfo, uiProperty, puiDataType, piValue,
173 pftValue, szValueBuf, pcchValueBuf);
175 suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
176 if( !suminfo )
177 return ERROR_INVALID_HANDLE;
179 spec.ulKind = PRSPEC_PROPID;
180 spec.DUMMYUNIONNAME.propid = uiProperty;
182 r = IPropertyStorage_ReadMultiple( suminfo->propstg, 1, &spec, &var);
183 if( FAILED(r) )
184 return ERROR_FUNCTION_FAILED;
186 if( puiDataType )
187 *puiDataType = var.vt;
189 switch( var.vt )
191 case VT_I4:
192 if( piValue )
193 *piValue = var.DUMMYUNIONNAME.lVal;
194 break;
195 case VT_LPSTR:
196 if( pcchValueBuf && szValueBuf )
198 lstrcpynA(szValueBuf, var.DUMMYUNIONNAME.pszVal, *pcchValueBuf );
199 *pcchValueBuf = lstrlenA( var.DUMMYUNIONNAME.pszVal );
201 break;
202 case VT_FILETIME:
203 if( pftValue )
204 memcpy(pftValue, &var.DUMMYUNIONNAME.filetime, sizeof (FILETIME) );
205 break;
206 case VT_EMPTY:
207 break;
208 default:
209 FIXME("Unknown property variant type\n");
210 break;
213 return ERROR_SUCCESS;
216 UINT WINAPI MsiSummaryInfoGetPropertyW(
217 MSIHANDLE hSummaryInfo, UINT uiProperty, UINT *puiDataType, INT *piValue,
218 FILETIME *pftValue, LPWSTR szValueBuf, DWORD *pcchValueBuf)
220 FIXME("%ld %d %p %p %p %p %p\n",
221 hSummaryInfo, uiProperty, puiDataType, piValue,
222 pftValue, szValueBuf, pcchValueBuf);
224 return ERROR_CALL_NOT_IMPLEMENTED;