Use the SourceList functions to get the source path in
[wine] / dlls / msi / suminfo.c
1 /*
2  * Implementation of the Microsoft Installer (msi.dll)
3  *
4  * Copyright 2002, 2005 Mike McCormack for CodeWeavers
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22
23 #define COBJMACROS
24 #define NONAMELESSUNION
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "winnls.h"
30 #include "shlwapi.h"
31 #include "wine/debug.h"
32 #include "msi.h"
33 #include "msiquery.h"
34 #include "msidefs.h"
35 #include "msipriv.h"
36 #include "objidl.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(msi);
39
40 #define MSI_MAX_PROPS 20
41
42 #include "pshpack1.h"
43
44 typedef struct { 
45     WORD wByteOrder;
46     WORD wFormat;
47     DWORD dwOSVer;
48     CLSID clsID;
49     DWORD reserved;
50 } PROPERTYSETHEADER;
51
52 typedef struct { 
53     FMTID fmtid;
54     DWORD dwOffset;
55 } FORMATIDOFFSET;
56
57 typedef struct { 
58     DWORD cbSection;
59     DWORD cProperties;
60 } PROPERTYSECTIONHEADER; 
61  
62 typedef struct { 
63     DWORD propid;
64     DWORD dwOffset;
65 } PROPERTYIDOFFSET; 
66
67 typedef struct {
68     DWORD type;
69     union {
70         INT i4;
71         SHORT i2;
72         FILETIME ft;
73         struct {
74             DWORD len;
75             BYTE str[1];
76         } str;
77     } u;
78 } PROPERTY_DATA;
79  
80 #include "poppack.h"
81
82 #define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER))
83
84 typedef struct {
85     BOOL unicode;
86     union {
87        LPSTR a;
88        LPWSTR w;
89     } str;
90 } awstring;
91
92 typedef struct {
93     BOOL unicode;
94     union {
95        LPCSTR a;
96        LPCWSTR w;
97     } str;
98 } awcstring;
99
100 typedef struct tagMSISUMMARYINFO
101 {
102     MSIOBJECTHDR hdr;
103     MSIDATABASE *db;
104     DWORD update_count;
105     PROPVARIANT property[MSI_MAX_PROPS];
106 } MSISUMMARYINFO;
107
108 static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
109                        'I','n','f','o','r','m','a','t','i','o','n',0 };
110
111 static void free_prop( PROPVARIANT *prop )
112 {
113     if (prop->vt == VT_LPSTR )
114         HeapFree( GetProcessHeap(), 0, prop->u.pszVal );
115     prop->vt = VT_EMPTY;
116 }
117
118 static void MSI_CloseSummaryInfo( MSIOBJECTHDR *arg )
119 {
120     MSISUMMARYINFO *si = (MSISUMMARYINFO *) arg;
121     DWORD i;
122
123     for( i = 0; i < MSI_MAX_PROPS; i++ )
124         free_prop( &si->property[i] );
125     msiobj_release( &si->db->hdr );
126 }
127
128 static UINT get_type( UINT uiProperty )
129 {
130     switch( uiProperty )
131     {
132     case PID_CODEPAGE:
133          return VT_I2;
134     
135     case PID_SUBJECT:
136     case PID_AUTHOR:
137     case PID_KEYWORDS:
138     case PID_COMMENTS:
139     case PID_TEMPLATE:
140     case PID_LASTAUTHOR:
141     case PID_REVNUMBER:
142     case PID_APPNAME:
143     case PID_TITLE:
144          return VT_LPSTR;
145
146     case PID_LASTPRINTED:
147     case PID_CREATE_DTM:
148     case PID_LASTSAVE_DTM:
149          return VT_FILETIME;
150
151     case PID_WORDCOUNT:
152     case PID_CHARCOUNT:
153     case PID_SECURITY:
154     case PID_PAGECOUNT:
155          return VT_I4;
156     }
157     return VT_EMPTY;
158 }
159
160 static UINT get_property_count( PROPVARIANT *property )
161 {
162     UINT i, n = 0;
163
164     if( !property )
165         return n;
166     for( i = 0; i < MSI_MAX_PROPS; i++ )
167         if( property[i].vt != VT_EMPTY )
168             n++;
169     return n;
170 }
171
172 /* FIXME: doesn't deal with endian conversion */
173 static void read_properties_from_data( PROPVARIANT *prop, LPBYTE data, DWORD sz )
174 {
175     UINT type;
176     DWORD i;
177     int size;
178     PROPERTY_DATA *propdata;
179     PROPVARIANT *property;
180     PROPERTYIDOFFSET *idofs;
181     PROPERTYSECTIONHEADER *section_hdr;
182
183     section_hdr = (PROPERTYSECTIONHEADER*) &data[0];
184     idofs = (PROPERTYIDOFFSET*) &data[SECT_HDR_SIZE];
185
186     /* now set all the properties */
187     for( i = 0; i < section_hdr->cProperties; i++ )
188     {
189         type = get_type( idofs[i].propid );
190         if( type == VT_EMPTY )
191         {
192             ERR("propid %ld has unknown type\n", idofs[i].propid);
193             break;
194         }
195
196         propdata = (PROPERTY_DATA*) &data[ idofs[i].dwOffset ];
197
198         /* check the type is the same as we expect */
199         if( type != propdata->type )
200         {
201             ERR("wrong type %d != %ld\n", type, propdata->type);
202             break;
203         }
204
205         /* check we don't run off the end of the data */
206         size = sz - idofs[i].dwOffset - sizeof(DWORD);
207         if( sizeof(DWORD) > size ||
208             ( type == VT_FILETIME && sizeof(FILETIME) > size ) ||
209             ( type == VT_LPSTR && (propdata->u.str.len + sizeof(DWORD)) > size ) )
210         {
211             ERR("not enough data\n");
212             break;
213         }
214
215         if( idofs[i].propid >= MSI_MAX_PROPS )
216         {
217             ERR("Unknown property ID %ld\n", idofs[i].propid );
218             break;
219         }
220
221         property = &prop[ idofs[i].propid ];
222         property->vt = type;
223
224         if( type == VT_LPSTR )
225         {
226             LPSTR str = HeapAlloc( GetProcessHeap(), 0, propdata->u.str.len );
227             memcpy( str, propdata->u.str.str, propdata->u.str.len );
228             str[ propdata->u.str.len - 1 ] = 0;
229             property->u.pszVal = str;
230         }
231         else if( type == VT_FILETIME )
232             property->u.filetime = propdata->u.ft;
233         else if( type == VT_I2 )
234             property->u.iVal = propdata->u.i2;
235         else if( type == VT_I4 )
236             property->u.lVal = propdata->u.i4;
237     }
238 }
239
240 static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm )
241 {
242     UINT ret = ERROR_FUNCTION_FAILED;
243     PROPERTYSETHEADER set_hdr;
244     FORMATIDOFFSET format_hdr;
245     PROPERTYSECTIONHEADER section_hdr;
246     LPBYTE data = NULL;
247     LARGE_INTEGER ofs;
248     ULONG count, sz;
249     HRESULT r;
250
251     TRACE("%p %p\n", si, stm);
252
253     /* read the header */
254     sz = sizeof set_hdr;
255     r = IStream_Read( stm, &set_hdr, sz, &count );
256     if( FAILED(r) || count != sz )
257         return ret;
258
259     if( set_hdr.wByteOrder != 0xfffe )
260     {
261         ERR("property set not big-endian %04X\n", set_hdr.wByteOrder);
262         return ret;
263     }
264
265     sz = sizeof format_hdr;
266     r = IStream_Read( stm, &format_hdr, sz, &count );
267     if( FAILED(r) || count != sz )
268         return ret;
269
270     /* check the format id is correct */
271     if( !IsEqualGUID( &FMTID_SummaryInformation, &format_hdr.fmtid ) )
272         return ret;
273
274     /* seek to the location of the section */
275     ofs.QuadPart = format_hdr.dwOffset;
276     r = IStream_Seek( stm, ofs, STREAM_SEEK_SET, NULL );
277     if( FAILED(r) )
278         return ret;
279
280     /* read the section itself */
281     sz = SECT_HDR_SIZE;
282     r = IStream_Read( stm, &section_hdr, sz, &count );
283     if( FAILED(r) || count != sz )
284         return ret;
285
286     if( section_hdr.cProperties > MSI_MAX_PROPS )
287     {
288         ERR("too many properties %ld\n", section_hdr.cProperties);
289         return ret;
290     }
291
292     data = HeapAlloc( GetProcessHeap(), 0, section_hdr.cbSection);
293     if( !data )
294         return ret;
295
296     memcpy( data, &section_hdr, SECT_HDR_SIZE );
297
298     /* read all the data in one go */
299     sz = section_hdr.cbSection - SECT_HDR_SIZE;
300     r = IStream_Read( stm, &data[ SECT_HDR_SIZE ], sz, &count );
301     if( SUCCEEDED(r) && count == sz )
302         read_properties_from_data( si->property, data, sz + SECT_HDR_SIZE );
303     else
304         ERR("failed to read properties %ld %ld\n", count, sz);
305
306     HeapFree( GetProcessHeap(), 0, data );
307     return ret;
308 }
309
310 static DWORD write_dword( LPBYTE data, DWORD ofs, DWORD val )
311 {
312     if( data )
313     {
314         data[ofs++] = val&0xff;
315         data[ofs++] = (val>>8)&0xff;
316         data[ofs++] = (val>>16)&0xff;
317         data[ofs++] = (val>>24)&0xff;
318     }
319     return 4;
320 }
321
322 static DWORD write_filetime( LPBYTE data, DWORD ofs, LPFILETIME ft )
323 {
324     write_dword( data, ofs, ft->dwLowDateTime );
325     write_dword( data, ofs + 4, ft->dwHighDateTime );
326     return 8;
327 }
328
329 static DWORD write_string( LPBYTE data, DWORD ofs, LPCSTR str )
330 {
331     DWORD len = lstrlenA( str ) + 1;
332     write_dword( data, ofs, len );
333     if( data )
334         memcpy( &data[ofs + 4], str, len );
335     return (7 + len) & ~3;
336 }
337
338 static UINT write_property_to_data( PROPVARIANT *prop, LPBYTE data )
339 {
340     DWORD sz = 0;
341
342     if( prop->vt == VT_EMPTY )
343         return sz;
344
345     /* add the type */
346     sz += write_dword( data, sz, prop->vt );
347     switch( prop->vt )
348     {
349     case VT_I2:
350         sz += write_dword( data, sz, prop->u.iVal );
351         break;
352     case VT_I4:
353         sz += write_dword( data, sz, prop->u.lVal );
354         break;
355     case VT_FILETIME:
356         sz += write_filetime( data, sz, &prop->u.filetime );
357         break;
358     case VT_LPSTR:
359         sz += write_string( data, sz, prop->u.pszVal );
360         break;
361     }
362     return sz;
363 }
364
365 static UINT save_summary_info( MSISUMMARYINFO * si, IStream *stm )
366 {
367     UINT ret = ERROR_FUNCTION_FAILED;
368     PROPERTYSETHEADER set_hdr;
369     FORMATIDOFFSET format_hdr;
370     PROPERTYSECTIONHEADER section_hdr;
371     PROPERTYIDOFFSET idofs[MSI_MAX_PROPS];
372     LPBYTE data = NULL;
373     ULONG count, sz;
374     HRESULT r;
375     int i, n;
376
377     /* write the header */
378     sz = sizeof set_hdr;
379     memset( &set_hdr, 0, sz );
380     set_hdr.wByteOrder = 0xfffe;
381     set_hdr.wFormat = 0;
382     set_hdr.dwOSVer = 0x00020005; /* build 5, platform id 2 */
383     /* set_hdr.clsID is {00000000-0000-0000-0000-000000000000} */
384     set_hdr.reserved = 1;
385     r = IStream_Write( stm, &set_hdr, sz, &count );
386     if( FAILED(r) || count != sz )
387         return ret;
388
389     /* write the format header */
390     sz = sizeof format_hdr;
391     memcpy( &format_hdr.fmtid, &FMTID_SummaryInformation, sizeof (FMTID) );
392     format_hdr.dwOffset = sizeof format_hdr + sizeof set_hdr;
393     r = IStream_Write( stm, &format_hdr, sz, &count );
394     if( FAILED(r) || count != sz )
395         return ret;
396
397     /* add up how much space the data will take and calculate the offsets */
398     section_hdr.cbSection = sizeof section_hdr;
399     section_hdr.cbSection += (get_property_count( si->property ) * sizeof idofs[0]);
400     section_hdr.cProperties = 0;
401     n = 0;
402     for( i = 0; i < MSI_MAX_PROPS; i++ )
403     {
404         sz = write_property_to_data( &si->property[i], NULL );
405         if( !sz )
406             continue;
407         idofs[ section_hdr.cProperties ].propid = i;
408         idofs[ section_hdr.cProperties ].dwOffset = section_hdr.cbSection;
409         section_hdr.cProperties++;
410         section_hdr.cbSection += sz;
411     }
412
413     data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, section_hdr.cbSection );
414
415     sz = 0;
416     memcpy( &data[sz], &section_hdr, sizeof section_hdr );
417     sz += sizeof section_hdr;
418
419     memcpy( &data[sz], idofs, section_hdr.cProperties * sizeof idofs[0] );
420     sz += section_hdr.cProperties * sizeof idofs[0];
421
422     /* write out the data */
423     for( i = 0; i < MSI_MAX_PROPS; i++ )
424         sz += write_property_to_data( &si->property[i], &data[sz] );
425
426     r = IStream_Write( stm, data, sz, &count );
427     HeapFree( GetProcessHeap(), 0, data );
428     if( FAILED(r) || count != sz )
429         return ret;
430
431     return ERROR_SUCCESS;
432 }
433
434 UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase, 
435               LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle )
436 {
437     UINT ret = ERROR_SUCCESS;
438     IStream *stm = NULL;
439     MSISUMMARYINFO *si;
440     MSIHANDLE handle;
441     MSIDATABASE *db;
442     DWORD grfMode;
443     HRESULT r;
444
445     TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
446            uiUpdateCount, pHandle);
447
448     if( !pHandle )
449         return ERROR_INVALID_PARAMETER;
450
451     if( szDatabase )
452     {
453         UINT res;
454
455         res = MSI_OpenDatabaseW(szDatabase, NULL, &db);
456         if( res != ERROR_SUCCESS )
457             return res;
458     }
459     else
460     {
461         db = msihandle2msiinfo(hDatabase, MSIHANDLETYPE_DATABASE);
462         if( !db )
463             return ERROR_INVALID_PARAMETER;
464     }
465
466     si = alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO, 
467                   sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo );
468     if( !si )
469     {
470         ret = ERROR_FUNCTION_FAILED;
471         goto end;
472     }
473
474     msiobj_addref( &db->hdr );
475     si->db = db;
476     memset( &si->property, 0, sizeof si->property );
477     si->update_count = uiUpdateCount;
478
479     /* read the stream... if we fail, we'll start with an empty property set */
480     grfMode = STGM_READ | STGM_SHARE_EXCLUSIVE;
481     r = IStorage_OpenStream( si->db->storage, szSumInfo, 0, grfMode, 0, &stm );
482     if( SUCCEEDED(r) )
483     {
484         load_summary_info( si, stm );
485         IStream_Release( stm );
486     }
487
488     handle = alloc_msihandle( &si->hdr );
489     if( handle )
490         *pHandle = handle;
491     else
492         ret = ERROR_FUNCTION_FAILED;
493     msiobj_release( &si->hdr );
494
495 end:
496     if( db )
497         msiobj_release( &db->hdr );
498
499     return ret;
500 }
501
502 UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, 
503               LPCSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
504 {
505     LPWSTR szwDatabase = NULL;
506     UINT ret;
507
508     TRACE("%ld %s %d %p\n", hDatabase, debugstr_a(szDatabase), 
509           uiUpdateCount, pHandle);
510
511     if( szDatabase )
512     {
513         szwDatabase = strdupAtoW( szDatabase );
514         if( !szwDatabase )
515             return ERROR_FUNCTION_FAILED;
516     }
517
518     ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, pHandle);
519
520     HeapFree( GetProcessHeap(), 0, szwDatabase );
521
522     return ret;
523 }
524
525 UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
526 {
527     MSISUMMARYINFO *si;
528
529     TRACE("%ld %p\n",hSummaryInfo, pCount);
530
531     si = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
532     if( !si )
533         return ERROR_INVALID_HANDLE;
534
535     if( pCount )
536         *pCount = get_property_count( si->property );
537     msiobj_release( &si->hdr );
538
539     return ERROR_SUCCESS;
540 }
541
542 static UINT get_prop( MSIHANDLE handle, UINT uiProperty, UINT *puiDataType,
543           INT *piValue, FILETIME *pftValue, awstring *str, DWORD *pcchValueBuf)
544 {
545     MSISUMMARYINFO *si;
546     PROPVARIANT *prop;
547
548     TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
549           piValue, pftValue, str, pcchValueBuf);
550
551     si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
552     if( !si )
553         return ERROR_INVALID_HANDLE;
554
555     prop = &si->property[uiProperty];
556
557     if( puiDataType )
558         *puiDataType = prop->vt;
559
560     switch( prop->vt )
561     {
562     case VT_I2:
563         if( piValue )
564             *piValue = prop->u.iVal;
565         break;
566     case VT_I4:
567         if( piValue )
568             *piValue = prop->u.lVal;
569         break;
570     case VT_LPSTR:
571         if( pcchValueBuf )
572         {
573             DWORD len = 0;
574
575             if( str->unicode )
576             {
577                 len = MultiByteToWideChar( CP_ACP, 0, prop->u.pszVal, -1,
578                                            str->str.w, *pcchValueBuf );
579             }
580             else
581             {
582                 len = lstrlenA( prop->u.pszVal );
583                 if( str->str.a )
584                     lstrcpynA(str->str.a, prop->u.pszVal, *pcchValueBuf );
585             }
586             *pcchValueBuf = len;
587         }
588         break;
589     case VT_FILETIME:
590         if( pftValue )
591             memcpy(pftValue, &prop->u.filetime, sizeof (FILETIME) );
592         break;
593     case VT_EMPTY:
594         break;
595     default:
596         FIXME("Unknown property variant type\n");
597         break;
598     }
599     msiobj_release( &si->hdr );
600     return ERROR_SUCCESS;
601 }
602
603 UINT WINAPI MsiSummaryInfoGetPropertyA(
604       MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue,
605       FILETIME *pftValue, LPSTR szValueBuf, DWORD *pcchValueBuf)
606 {
607     awstring str;
608
609     TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
610           piValue, pftValue, szValueBuf, pcchValueBuf );
611
612     str.unicode = FALSE;
613     str.str.a = szValueBuf;
614
615     return get_prop( handle, uiProperty, puiDataType, piValue,
616                      pftValue, &str, pcchValueBuf );
617 }
618
619 UINT WINAPI MsiSummaryInfoGetPropertyW(
620       MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue,
621       FILETIME *pftValue, LPWSTR szValueBuf, DWORD *pcchValueBuf)
622 {
623     awstring str;
624
625     TRACE("%ld %d %p %p %p %p %p\n", handle, uiProperty, puiDataType,
626           piValue, pftValue, szValueBuf, pcchValueBuf );
627
628     str.unicode = TRUE;
629     str.str.w = szValueBuf;
630
631     return get_prop( handle, uiProperty, puiDataType, piValue,
632                      pftValue, &str, pcchValueBuf );
633 }
634
635 static UINT set_prop( MSIHANDLE handle, UINT uiProperty, UINT uiDataType,
636                INT iValue, FILETIME* pftValue, awcstring *str )
637 {
638     MSISUMMARYINFO *si;
639     PROPVARIANT *prop;
640     UINT type, len, ret = ERROR_SUCCESS;
641
642     TRACE("%ld %u %u %i %p %p\n", handle, uiProperty, uiDataType,
643           iValue, pftValue, str );
644
645     type = get_type( uiProperty );
646     if( type == VT_EMPTY || type != uiDataType )
647         return ERROR_DATATYPE_MISMATCH;
648
649     if( uiDataType == VT_LPSTR && !str->str.w )
650         return ERROR_INVALID_PARAMETER;
651
652     if( uiDataType == VT_FILETIME && !pftValue )
653         return ERROR_INVALID_PARAMETER;
654
655     si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
656     if( !si )
657         return ERROR_INVALID_HANDLE;
658
659     prop = &si->property[uiProperty];
660
661     if( prop->vt == VT_EMPTY )
662     {
663         if( !si->update_count )
664         {
665             ret = ERROR_FUNCTION_FAILED;
666             goto end;
667         }
668         si->update_count--;
669     }
670     else if( prop->vt != type )
671         goto end;
672
673     free_prop( prop );
674     prop->vt = type;
675     switch( type )
676     {
677     case VT_I4:
678         prop->u.lVal = iValue;
679         break;
680     case VT_I2:
681         prop->u.iVal = iValue;
682         break;
683     case VT_FILETIME:
684         memcpy( &prop->u.filetime, pftValue, sizeof prop->u.filetime );
685         break;
686     case VT_LPSTR:
687         if( str->unicode )
688         {
689             len = WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
690                                        NULL, 0, NULL, NULL );
691             prop->u.pszVal = HeapAlloc( GetProcessHeap(), 0, len );
692             WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
693                                  prop->u.pszVal, len, NULL, NULL );
694         }
695         else
696         {
697             len = lstrlenA( str->str.a ) + 1;
698             prop->u.pszVal = HeapAlloc( GetProcessHeap(), 0, len );
699             lstrcpyA( prop->u.pszVal, str->str.a );
700         }
701         break;
702     }
703
704 end:
705     msiobj_release( &si->hdr );
706     return ret;
707 }
708
709 UINT WINAPI MsiSummaryInfoSetPropertyW( MSIHANDLE handle, UINT uiProperty,
710                UINT uiDataType, INT iValue, FILETIME* pftValue, LPCWSTR szValue )
711 {
712     awcstring str;
713
714     TRACE("%ld %u %u %i %p %s\n", handle, uiProperty, uiDataType,
715           iValue, pftValue, debugstr_w(szValue) );
716
717     str.unicode = TRUE;
718     str.str.w = szValue;
719     return set_prop( handle, uiProperty, uiDataType, iValue, pftValue, &str );
720 }
721
722 UINT WINAPI MsiSummaryInfoSetPropertyA( MSIHANDLE handle, UINT uiProperty,
723                UINT uiDataType, INT iValue, FILETIME* pftValue, LPCSTR szValue )
724 {
725     awcstring str;
726
727     TRACE("%ld %u %u %i %p %s\n", handle, uiProperty, uiDataType,
728           iValue, pftValue, debugstr_a(szValue) );
729
730     str.unicode = FALSE;
731     str.str.a = szValue;
732     return set_prop( handle, uiProperty, uiDataType, iValue, pftValue, &str );
733 }
734
735 UINT WINAPI MsiSummaryInfoPersist( MSIHANDLE handle )
736 {
737     IStream *stm = NULL;
738     MSISUMMARYINFO *si;
739     DWORD grfMode;
740     HRESULT r;
741     UINT ret = ERROR_FUNCTION_FAILED;
742
743     TRACE("%ld\n", handle );
744
745     si = msihandle2msiinfo( handle, MSIHANDLETYPE_SUMMARYINFO );
746     if( !si )
747         return ERROR_INVALID_HANDLE;
748
749     grfMode = STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
750     r = IStorage_CreateStream( si->db->storage, szSumInfo, grfMode, 0, 0, &stm );
751     if( SUCCEEDED(r) )
752     {
753         ret = save_summary_info( si, stm );
754         IStream_Release( stm );
755     }
756     msiobj_release( &si->hdr );
757
758     return ret;
759 }