2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2002, 2005 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
28 #define NONAMELESSUNION
31 //#include "winbase.h"
34 //#include "shlwapi.h"
35 #include <wine/debug.h>
36 #include <wine/unicode.h>
39 #include <propvarutil.h>
41 //#include "msiquery.h"
45 #include <msiserver.h>
47 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
67 } PROPERTYSECTIONHEADER
;
89 static HRESULT (WINAPI
*pPropVariantChangeType
)
90 (PROPVARIANT
*ppropvarDest
, REFPROPVARIANT propvarSrc
,
91 PROPVAR_CHANGE_FLAGS flags
, VARTYPE vt
);
93 #define SECT_HDR_SIZE (sizeof(PROPERTYSECTIONHEADER))
95 static void free_prop( PROPVARIANT
*prop
)
97 if (prop
->vt
== VT_LPSTR
)
98 msi_free( prop
->u
.pszVal
);
102 static void MSI_CloseSummaryInfo( MSIOBJECTHDR
*arg
)
104 MSISUMMARYINFO
*si
= (MSISUMMARYINFO
*) arg
;
107 for( i
= 0; i
< MSI_MAX_PROPS
; i
++ )
108 free_prop( &si
->property
[i
] );
109 IStorage_Release( si
->storage
);
112 static UINT
get_type( UINT uiProperty
)
130 case PID_LASTPRINTED
:
132 case PID_LASTSAVE_DTM
:
144 static UINT
get_property_count( const PROPVARIANT
*property
)
150 for( i
= 0; i
< MSI_MAX_PROPS
; i
++ )
151 if( property
[i
].vt
!= VT_EMPTY
)
156 static UINT
propvar_changetype(PROPVARIANT
*changed
, PROPVARIANT
*property
, VARTYPE vt
)
159 HMODULE propsys
= LoadLibraryA("propsys.dll");
160 pPropVariantChangeType
= (void *)GetProcAddress(propsys
, "PropVariantChangeType");
162 if (!pPropVariantChangeType
)
164 ERR("PropVariantChangeType function missing!\n");
165 return ERROR_FUNCTION_FAILED
;
168 hr
= pPropVariantChangeType(changed
, property
, 0, vt
);
169 return (hr
== S_OK
) ? ERROR_SUCCESS
: ERROR_FUNCTION_FAILED
;
172 /* FIXME: doesn't deal with endian conversion */
173 static void read_properties_from_data( PROPVARIANT
*prop
, LPBYTE data
, DWORD sz
)
177 PROPERTY_DATA
*propdata
;
178 PROPVARIANT property
, *ptr
;
180 PROPERTYIDOFFSET
*idofs
;
181 PROPERTYSECTIONHEADER
*section_hdr
;
183 section_hdr
= (PROPERTYSECTIONHEADER
*) &data
[0];
184 idofs
= (PROPERTYIDOFFSET
*) &data
[SECT_HDR_SIZE
];
186 /* now set all the properties */
187 for( i
= 0; i
< section_hdr
->cProperties
; i
++ )
189 if( idofs
[i
].propid
>= MSI_MAX_PROPS
)
191 ERR("Unknown property ID %d\n", idofs
[i
].propid
);
195 type
= get_type( idofs
[i
].propid
);
196 if( type
== VT_EMPTY
)
198 ERR("propid %d has unknown type\n", idofs
[i
].propid
);
202 propdata
= (PROPERTY_DATA
*) &data
[ idofs
[i
].dwOffset
];
204 /* check we don't run off the end of the data */
205 size
= sz
- idofs
[i
].dwOffset
- sizeof(DWORD
);
206 if( sizeof(DWORD
) > size
||
207 ( propdata
->type
== VT_FILETIME
&& sizeof(FILETIME
) > size
) ||
208 ( propdata
->type
== VT_LPSTR
&& (propdata
->u
.str
.len
+ sizeof(DWORD
)) > size
) )
210 ERR("not enough data\n");
214 property
.vt
= propdata
->type
;
215 if( propdata
->type
== VT_LPSTR
)
217 LPSTR str
= msi_alloc( propdata
->u
.str
.len
);
218 memcpy( str
, propdata
->u
.str
.str
, propdata
->u
.str
.len
);
219 str
[ propdata
->u
.str
.len
- 1 ] = 0;
220 property
.u
.pszVal
= str
;
222 else if( propdata
->type
== VT_FILETIME
)
223 property
.u
.filetime
= propdata
->u
.ft
;
224 else if( propdata
->type
== VT_I2
)
225 property
.u
.iVal
= propdata
->u
.i2
;
226 else if( propdata
->type
== VT_I4
)
227 property
.u
.lVal
= propdata
->u
.i4
;
229 /* check the type is the same as we expect */
230 if( type
!= propdata
->type
)
232 propvar_changetype(&changed
, &property
, type
);
238 prop
[ idofs
[i
].propid
] = *ptr
;
242 static UINT
load_summary_info( MSISUMMARYINFO
*si
, IStream
*stm
)
244 UINT ret
= ERROR_FUNCTION_FAILED
;
245 PROPERTYSETHEADER set_hdr
;
246 FORMATIDOFFSET format_hdr
;
247 PROPERTYSECTIONHEADER section_hdr
;
253 TRACE("%p %p\n", si
, stm
);
255 /* read the header */
257 r
= IStream_Read( stm
, &set_hdr
, sz
, &count
);
258 if( FAILED(r
) || count
!= sz
)
261 if( set_hdr
.wByteOrder
!= 0xfffe )
263 ERR("property set not big-endian %04X\n", set_hdr
.wByteOrder
);
267 sz
= sizeof format_hdr
;
268 r
= IStream_Read( stm
, &format_hdr
, sz
, &count
);
269 if( FAILED(r
) || count
!= sz
)
272 /* check the format id is correct */
273 if( !IsEqualGUID( &FMTID_SummaryInformation
, &format_hdr
.fmtid
) )
276 /* seek to the location of the section */
277 ofs
.QuadPart
= format_hdr
.dwOffset
;
278 r
= IStream_Seek( stm
, ofs
, STREAM_SEEK_SET
, NULL
);
282 /* read the section itself */
284 r
= IStream_Read( stm
, §ion_hdr
, sz
, &count
);
285 if( FAILED(r
) || count
!= sz
)
288 if( section_hdr
.cProperties
> MSI_MAX_PROPS
)
290 ERR("too many properties %d\n", section_hdr
.cProperties
);
294 data
= msi_alloc( section_hdr
.cbSection
);
298 memcpy( data
, §ion_hdr
, SECT_HDR_SIZE
);
300 /* read all the data in one go */
301 sz
= section_hdr
.cbSection
- SECT_HDR_SIZE
;
302 r
= IStream_Read( stm
, &data
[ SECT_HDR_SIZE
], sz
, &count
);
303 if( SUCCEEDED(r
) && count
== sz
)
304 read_properties_from_data( si
->property
, data
, sz
+ SECT_HDR_SIZE
);
306 ERR("failed to read properties %d %d\n", count
, sz
);
312 static DWORD
write_dword( LPBYTE data
, DWORD ofs
, DWORD val
)
316 data
[ofs
++] = val
&0xff;
317 data
[ofs
++] = (val
>>8)&0xff;
318 data
[ofs
++] = (val
>>16)&0xff;
319 data
[ofs
++] = (val
>>24)&0xff;
324 static DWORD
write_filetime( LPBYTE data
, DWORD ofs
, const FILETIME
*ft
)
326 write_dword( data
, ofs
, ft
->dwLowDateTime
);
327 write_dword( data
, ofs
+ 4, ft
->dwHighDateTime
);
331 static DWORD
write_string( LPBYTE data
, DWORD ofs
, LPCSTR str
)
333 DWORD len
= lstrlenA( str
) + 1;
334 write_dword( data
, ofs
, len
);
336 memcpy( &data
[ofs
+ 4], str
, len
);
337 return (7 + len
) & ~3;
340 static UINT
write_property_to_data( const PROPVARIANT
*prop
, LPBYTE data
)
344 if( prop
->vt
== VT_EMPTY
)
348 sz
+= write_dword( data
, sz
, prop
->vt
);
352 sz
+= write_dword( data
, sz
, prop
->u
.iVal
);
355 sz
+= write_dword( data
, sz
, prop
->u
.lVal
);
358 sz
+= write_filetime( data
, sz
, &prop
->u
.filetime
);
361 sz
+= write_string( data
, sz
, prop
->u
.pszVal
);
367 static UINT
save_summary_info( const MSISUMMARYINFO
* si
, IStream
*stm
)
369 UINT ret
= ERROR_FUNCTION_FAILED
;
370 PROPERTYSETHEADER set_hdr
;
371 FORMATIDOFFSET format_hdr
;
372 PROPERTYSECTIONHEADER section_hdr
;
373 PROPERTYIDOFFSET idofs
[MSI_MAX_PROPS
];
379 /* write the header */
381 memset( &set_hdr
, 0, sz
);
382 set_hdr
.wByteOrder
= 0xfffe;
384 set_hdr
.dwOSVer
= 0x00020005; /* build 5, platform id 2 */
385 /* set_hdr.clsID is {00000000-0000-0000-0000-000000000000} */
386 set_hdr
.reserved
= 1;
387 r
= IStream_Write( stm
, &set_hdr
, sz
, &count
);
388 if( FAILED(r
) || count
!= sz
)
391 /* write the format header */
392 sz
= sizeof format_hdr
;
393 format_hdr
.fmtid
= FMTID_SummaryInformation
;
394 format_hdr
.dwOffset
= sizeof format_hdr
+ sizeof set_hdr
;
395 r
= IStream_Write( stm
, &format_hdr
, sz
, &count
);
396 if( FAILED(r
) || count
!= sz
)
399 /* add up how much space the data will take and calculate the offsets */
400 section_hdr
.cbSection
= sizeof section_hdr
;
401 section_hdr
.cbSection
+= (get_property_count( si
->property
) * sizeof idofs
[0]);
402 section_hdr
.cProperties
= 0;
403 for( i
= 0; i
< MSI_MAX_PROPS
; i
++ )
405 sz
= write_property_to_data( &si
->property
[i
], NULL
);
408 idofs
[ section_hdr
.cProperties
].propid
= i
;
409 idofs
[ section_hdr
.cProperties
].dwOffset
= section_hdr
.cbSection
;
410 section_hdr
.cProperties
++;
411 section_hdr
.cbSection
+= sz
;
414 data
= msi_alloc_zero( section_hdr
.cbSection
);
417 memcpy( &data
[sz
], §ion_hdr
, sizeof section_hdr
);
418 sz
+= sizeof section_hdr
;
420 memcpy( &data
[sz
], idofs
, section_hdr
.cProperties
* sizeof idofs
[0] );
421 sz
+= section_hdr
.cProperties
* sizeof idofs
[0];
423 /* write out the data */
424 for( i
= 0; i
< MSI_MAX_PROPS
; i
++ )
425 sz
+= write_property_to_data( &si
->property
[i
], &data
[sz
] );
427 r
= IStream_Write( stm
, data
, sz
, &count
);
429 if( FAILED(r
) || count
!= sz
)
432 return ERROR_SUCCESS
;
435 MSISUMMARYINFO
*MSI_GetSummaryInformationW( IStorage
*stg
, UINT uiUpdateCount
)
442 TRACE("%p %d\n", stg
, uiUpdateCount
);
444 si
= alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO
,
445 sizeof (MSISUMMARYINFO
), MSI_CloseSummaryInfo
);
449 si
->update_count
= uiUpdateCount
;
450 IStorage_AddRef( stg
);
453 /* read the stream... if we fail, we'll start with an empty property set */
454 grfMode
= STGM_READ
| STGM_SHARE_EXCLUSIVE
;
455 r
= IStorage_OpenStream( si
->storage
, szSumInfo
, 0, grfMode
, 0, &stm
);
458 load_summary_info( si
, stm
);
459 IStream_Release( stm
);
465 UINT WINAPI
MsiGetSummaryInformationW( MSIHANDLE hDatabase
,
466 LPCWSTR szDatabase
, UINT uiUpdateCount
, MSIHANDLE
*pHandle
)
470 UINT ret
= ERROR_FUNCTION_FAILED
;
472 TRACE("%d %s %d %p\n", hDatabase
, debugstr_w(szDatabase
),
473 uiUpdateCount
, pHandle
);
476 return ERROR_INVALID_PARAMETER
;
478 if( szDatabase
&& szDatabase
[0] )
480 LPCWSTR persist
= uiUpdateCount
? MSIDBOPEN_TRANSACT
: MSIDBOPEN_READONLY
;
482 ret
= MSI_OpenDatabaseW( szDatabase
, persist
, &db
);
483 if( ret
!= ERROR_SUCCESS
)
488 db
= msihandle2msiinfo( hDatabase
, MSIHANDLETYPE_DATABASE
);
492 IWineMsiRemoteDatabase
*remote_database
;
494 remote_database
= (IWineMsiRemoteDatabase
*)msi_get_remote( hDatabase
);
495 if ( !remote_database
)
496 return ERROR_INVALID_HANDLE
;
498 hr
= IWineMsiRemoteDatabase_GetSummaryInformation( remote_database
,
499 uiUpdateCount
, pHandle
);
500 IWineMsiRemoteDatabase_Release( remote_database
);
504 if (HRESULT_FACILITY(hr
) == FACILITY_WIN32
)
505 return HRESULT_CODE(hr
);
507 return ERROR_FUNCTION_FAILED
;
510 return ERROR_SUCCESS
;
514 si
= MSI_GetSummaryInformationW( db
->storage
, uiUpdateCount
);
517 *pHandle
= alloc_msihandle( &si
->hdr
);
521 ret
= ERROR_NOT_ENOUGH_MEMORY
;
522 msiobj_release( &si
->hdr
);
525 msiobj_release( &db
->hdr
);
529 UINT WINAPI
MsiGetSummaryInformationA(MSIHANDLE hDatabase
,
530 LPCSTR szDatabase
, UINT uiUpdateCount
, MSIHANDLE
*pHandle
)
532 LPWSTR szwDatabase
= NULL
;
535 TRACE("%d %s %d %p\n", hDatabase
, debugstr_a(szDatabase
),
536 uiUpdateCount
, pHandle
);
540 szwDatabase
= strdupAtoW( szDatabase
);
542 return ERROR_FUNCTION_FAILED
;
545 ret
= MsiGetSummaryInformationW(hDatabase
, szwDatabase
, uiUpdateCount
, pHandle
);
547 msi_free( szwDatabase
);
552 UINT WINAPI
MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo
, PUINT pCount
)
556 TRACE("%d %p\n", hSummaryInfo
, pCount
);
558 si
= msihandle2msiinfo( hSummaryInfo
, MSIHANDLETYPE_SUMMARYINFO
);
560 return ERROR_INVALID_HANDLE
;
563 *pCount
= get_property_count( si
->property
);
564 msiobj_release( &si
->hdr
);
566 return ERROR_SUCCESS
;
569 static UINT
get_prop( MSIHANDLE handle
, UINT uiProperty
, UINT
*puiDataType
,
570 INT
*piValue
, FILETIME
*pftValue
, awstring
*str
, DWORD
*pcchValueBuf
)
574 UINT ret
= ERROR_SUCCESS
;
576 TRACE("%d %d %p %p %p %p %p\n", handle
, uiProperty
, puiDataType
,
577 piValue
, pftValue
, str
, pcchValueBuf
);
579 if ( uiProperty
>= MSI_MAX_PROPS
)
581 if (puiDataType
) *puiDataType
= VT_EMPTY
;
582 return ERROR_UNKNOWN_PROPERTY
;
585 si
= msihandle2msiinfo( handle
, MSIHANDLETYPE_SUMMARYINFO
);
587 return ERROR_INVALID_HANDLE
;
589 prop
= &si
->property
[uiProperty
];
592 *puiDataType
= prop
->vt
;
598 *piValue
= prop
->u
.iVal
;
602 *piValue
= prop
->u
.lVal
;
611 len
= MultiByteToWideChar( CP_ACP
, 0, prop
->u
.pszVal
, -1, NULL
, 0 ) - 1;
612 MultiByteToWideChar( CP_ACP
, 0, prop
->u
.pszVal
, -1, str
->str
.w
, *pcchValueBuf
);
616 len
= lstrlenA( prop
->u
.pszVal
);
618 lstrcpynA(str
->str
.a
, prop
->u
.pszVal
, *pcchValueBuf
);
620 if (len
>= *pcchValueBuf
)
621 ret
= ERROR_MORE_DATA
;
627 *pftValue
= prop
->u
.filetime
;
632 FIXME("Unknown property variant type\n");
635 msiobj_release( &si
->hdr
);
639 LPWSTR
msi_suminfo_dup_string( MSISUMMARYINFO
*si
, UINT uiProperty
)
643 if ( uiProperty
>= MSI_MAX_PROPS
)
645 prop
= &si
->property
[uiProperty
];
646 if( prop
->vt
!= VT_LPSTR
)
648 return strdupAtoW( prop
->u
.pszVal
);
651 INT
msi_suminfo_get_int32( MSISUMMARYINFO
*si
, UINT uiProperty
)
655 if ( uiProperty
>= MSI_MAX_PROPS
)
657 prop
= &si
->property
[uiProperty
];
658 if( prop
->vt
!= VT_I4
)
663 LPWSTR
msi_get_suminfo_product( IStorage
*stg
)
668 si
= MSI_GetSummaryInformationW( stg
, 0 );
671 ERR("no summary information!\n");
674 prod
= msi_suminfo_dup_string( si
, PID_REVNUMBER
);
675 msiobj_release( &si
->hdr
);
679 UINT WINAPI
MsiSummaryInfoGetPropertyA(
680 MSIHANDLE handle
, UINT uiProperty
, PUINT puiDataType
, LPINT piValue
,
681 FILETIME
*pftValue
, LPSTR szValueBuf
, LPDWORD pcchValueBuf
)
685 TRACE("%d %d %p %p %p %p %p\n", handle
, uiProperty
, puiDataType
,
686 piValue
, pftValue
, szValueBuf
, pcchValueBuf
);
689 str
.str
.a
= szValueBuf
;
691 return get_prop( handle
, uiProperty
, puiDataType
, piValue
,
692 pftValue
, &str
, pcchValueBuf
);
695 UINT WINAPI
MsiSummaryInfoGetPropertyW(
696 MSIHANDLE handle
, UINT uiProperty
, PUINT puiDataType
, LPINT piValue
,
697 FILETIME
*pftValue
, LPWSTR szValueBuf
, LPDWORD pcchValueBuf
)
701 TRACE("%d %d %p %p %p %p %p\n", handle
, uiProperty
, puiDataType
,
702 piValue
, pftValue
, szValueBuf
, pcchValueBuf
);
705 str
.str
.w
= szValueBuf
;
707 return get_prop( handle
, uiProperty
, puiDataType
, piValue
,
708 pftValue
, &str
, pcchValueBuf
);
711 static UINT
set_prop( MSISUMMARYINFO
*si
, UINT uiProperty
, UINT type
,
712 INT iValue
, FILETIME
* pftValue
, awcstring
*str
)
717 TRACE("%p %u %u %i %p %p\n", si
, uiProperty
, type
, iValue
,
720 prop
= &si
->property
[uiProperty
];
722 if( prop
->vt
== VT_EMPTY
)
724 if( !si
->update_count
)
725 return ERROR_FUNCTION_FAILED
;
729 else if( prop
->vt
!= type
)
730 return ERROR_SUCCESS
;
737 prop
->u
.lVal
= iValue
;
740 prop
->u
.iVal
= iValue
;
743 prop
->u
.filetime
= *pftValue
;
748 len
= WideCharToMultiByte( CP_ACP
, 0, str
->str
.w
, -1,
749 NULL
, 0, NULL
, NULL
);
750 prop
->u
.pszVal
= msi_alloc( len
);
751 WideCharToMultiByte( CP_ACP
, 0, str
->str
.w
, -1,
752 prop
->u
.pszVal
, len
, NULL
, NULL
);
756 len
= lstrlenA( str
->str
.a
) + 1;
757 prop
->u
.pszVal
= msi_alloc( len
);
758 lstrcpyA( prop
->u
.pszVal
, str
->str
.a
);
763 return ERROR_SUCCESS
;
766 UINT WINAPI
MsiSummaryInfoSetPropertyW( MSIHANDLE handle
, UINT uiProperty
,
767 UINT uiDataType
, INT iValue
, FILETIME
* pftValue
, LPCWSTR szValue
)
773 TRACE("%d %u %u %i %p %s\n", handle
, uiProperty
, uiDataType
,
774 iValue
, pftValue
, debugstr_w(szValue
) );
776 type
= get_type( uiProperty
);
777 if( type
== VT_EMPTY
|| type
!= uiDataType
)
778 return ERROR_DATATYPE_MISMATCH
;
780 if( uiDataType
== VT_LPSTR
&& !szValue
)
781 return ERROR_INVALID_PARAMETER
;
783 if( uiDataType
== VT_FILETIME
&& !pftValue
)
784 return ERROR_INVALID_PARAMETER
;
786 si
= msihandle2msiinfo( handle
, MSIHANDLETYPE_SUMMARYINFO
);
788 return ERROR_INVALID_HANDLE
;
792 ret
= set_prop( si
, uiProperty
, type
, iValue
, pftValue
, &str
);
794 msiobj_release( &si
->hdr
);
798 UINT WINAPI
MsiSummaryInfoSetPropertyA( MSIHANDLE handle
, UINT uiProperty
,
799 UINT uiDataType
, INT iValue
, FILETIME
* pftValue
, LPCSTR szValue
)
805 TRACE("%d %u %u %i %p %s\n", handle
, uiProperty
, uiDataType
,
806 iValue
, pftValue
, debugstr_a(szValue
) );
808 type
= get_type( uiProperty
);
809 if( type
== VT_EMPTY
|| type
!= uiDataType
)
810 return ERROR_DATATYPE_MISMATCH
;
812 if( uiDataType
== VT_LPSTR
&& !szValue
)
813 return ERROR_INVALID_PARAMETER
;
815 if( uiDataType
== VT_FILETIME
&& !pftValue
)
816 return ERROR_INVALID_PARAMETER
;
818 si
= msihandle2msiinfo( handle
, MSIHANDLETYPE_SUMMARYINFO
);
820 return ERROR_INVALID_HANDLE
;
824 ret
= set_prop( si
, uiProperty
, uiDataType
, iValue
, pftValue
, &str
);
826 msiobj_release( &si
->hdr
);
830 static UINT
suminfo_persist( MSISUMMARYINFO
*si
)
832 UINT ret
= ERROR_FUNCTION_FAILED
;
837 grfMode
= STGM_CREATE
| STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
;
838 r
= IStorage_CreateStream( si
->storage
, szSumInfo
, grfMode
, 0, 0, &stm
);
841 ret
= save_summary_info( si
, stm
);
842 IStream_Release( stm
);
847 static void parse_filetime( LPCWSTR str
, FILETIME
*ft
)
850 const WCHAR
*p
= str
;
853 memset( <
, 0, sizeof(lt
) );
855 /* YYYY/MM/DD hh:mm:ss */
857 while (isspaceW( *p
)) p
++;
859 lt
.wYear
= strtolW( p
, &end
, 10 );
860 if (*end
!= '/') return;
863 lt
.wMonth
= strtolW( p
, &end
, 10 );
864 if (*end
!= '/') return;
867 lt
.wDay
= strtolW( p
, &end
, 10 );
868 if (*end
!= ' ') return;
871 while (isspaceW( *p
)) p
++;
873 lt
.wHour
= strtolW( p
, &end
, 10 );
874 if (*end
!= ':') return;
877 lt
.wMinute
= strtolW( p
, &end
, 10 );
878 if (*end
!= ':') return;
881 lt
.wSecond
= strtolW( p
, &end
, 10 );
883 TzSpecificLocalTimeToSystemTime( NULL
, <
, &utc
);
884 SystemTimeToFileTime( &utc
, ft
);
887 static UINT
parse_prop( LPCWSTR prop
, LPCWSTR value
, UINT
*pid
, INT
*int_value
,
888 FILETIME
*ft_value
, awcstring
*str_value
)
890 *pid
= atoiW( prop
);
898 *int_value
= atoiW( value
);
901 case PID_LASTPRINTED
:
903 case PID_LASTSAVE_DTM
:
904 parse_filetime( value
, ft_value
);
916 str_value
->str
.w
= value
;
917 str_value
->unicode
= TRUE
;
921 WARN("unhandled prop id %u\n", *pid
);
922 return ERROR_FUNCTION_FAILED
;
925 return ERROR_SUCCESS
;
928 UINT
msi_add_suminfo( MSIDATABASE
*db
, LPWSTR
**records
, int num_records
, int num_columns
)
930 UINT r
= ERROR_FUNCTION_FAILED
;
934 si
= MSI_GetSummaryInformationW( db
->storage
, num_records
* (num_columns
/ 2) );
937 ERR("no summary information!\n");
938 return ERROR_FUNCTION_FAILED
;
941 for (i
= 0; i
< num_records
; i
++)
943 for (j
= 0; j
< num_columns
; j
+= 2)
950 r
= parse_prop( records
[i
][j
], records
[i
][j
+ 1], &pid
, &int_value
, &ft_value
, &str_value
);
951 if (r
!= ERROR_SUCCESS
)
954 r
= set_prop( si
, pid
, get_type(pid
), int_value
, &ft_value
, &str_value
);
955 if (r
!= ERROR_SUCCESS
)
961 if (r
== ERROR_SUCCESS
)
962 r
= suminfo_persist( si
);
964 msiobj_release( &si
->hdr
);
968 UINT WINAPI
MsiSummaryInfoPersist( MSIHANDLE handle
)
973 TRACE("%d\n", handle
);
975 si
= msihandle2msiinfo( handle
, MSIHANDLETYPE_SUMMARYINFO
);
977 return ERROR_INVALID_HANDLE
;
979 ret
= suminfo_persist( si
);
981 msiobj_release( &si
->hdr
);
985 UINT WINAPI
MsiCreateTransformSummaryInfoA( MSIHANDLE db
, MSIHANDLE db_ref
, LPCSTR transform
, int error
, int validation
)
988 WCHAR
*transformW
= NULL
;
990 TRACE("%u, %u, %s, %d, %d\n", db
, db_ref
, debugstr_a(transform
), error
, validation
);
992 if (transform
&& !(transformW
= strdupAtoW( transform
)))
993 return ERROR_OUTOFMEMORY
;
995 r
= MsiCreateTransformSummaryInfoW( db
, db_ref
, transformW
, error
, validation
);
996 msi_free( transformW
);
1000 UINT WINAPI
MsiCreateTransformSummaryInfoW( MSIHANDLE db
, MSIHANDLE db_ref
, LPCWSTR transform
, int error
, int validation
)
1002 FIXME("%u, %u, %s, %d, %d\n", db
, db_ref
, debugstr_w(transform
), error
, validation
);
1003 return ERROR_FUNCTION_FAILED
;