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
24 #define NONAMELESSUNION
31 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
39 static const WCHAR szSumInfo
[] = { 5 ,'S','u','m','m','a','r','y',
40 'I','n','f','o','r','m','a','t','i','o','n',0 };
42 static void MSI_CloseSummaryInfo( MSIOBJECTHDR
*arg
)
44 MSISUMMARYINFO
*suminfo
= (MSISUMMARYINFO
*) arg
;
45 IPropertyStorage_Release( suminfo
->propstg
);
48 UINT WINAPI
MsiGetSummaryInformationA(MSIHANDLE hDatabase
,
49 LPCSTR szDatabase
, UINT uiUpdateCount
, MSIHANDLE
*phSummaryInfo
)
51 LPWSTR szwDatabase
= NULL
;
54 TRACE("%ld %s %d %p\n", hDatabase
, debugstr_a(szDatabase
),
55 uiUpdateCount
, phSummaryInfo
);
59 UINT len
= MultiByteToWideChar( CP_ACP
, 0, szDatabase
, -1, NULL
, 0 );
60 szwDatabase
= HeapAlloc( GetProcessHeap(), 0, len
*sizeof(WCHAR
) );
62 return ERROR_FUNCTION_FAILED
;
63 MultiByteToWideChar( CP_ACP
, 0, szDatabase
, -1, szwDatabase
, len
);
66 ret
= MsiGetSummaryInformationW(hDatabase
, szwDatabase
, uiUpdateCount
, phSummaryInfo
);
69 HeapFree( GetProcessHeap(), 0, szwDatabase
);
74 UINT WINAPI
MsiGetSummaryInformationW(MSIHANDLE hDatabase
,
75 LPCWSTR szDatabase
, UINT uiUpdateCount
, MSIHANDLE
*phSummaryInfo
)
79 MSISUMMARYINFO
*suminfo
;
81 UINT ret
= ERROR_SUCCESS
;
82 IPropertySetStorage
*psstg
= NULL
;
83 IPropertyStorage
*ps
= NULL
;
86 TRACE("%ld %s %d %p\n", hDatabase
, debugstr_w(szDatabase
),
87 uiUpdateCount
, phSummaryInfo
);
90 return ERROR_INVALID_PARAMETER
;
96 res
= MSI_OpenDatabaseW(szDatabase
, NULL
, &db
);
97 if( res
!= ERROR_SUCCESS
)
102 db
= msihandle2msiinfo(hDatabase
, MSIHANDLETYPE_DATABASE
);
104 return ERROR_INVALID_PARAMETER
;
107 r
= IStorage_QueryInterface( db
->storage
,
108 &IID_IPropertySetStorage
, (LPVOID
)&psstg
);
111 ERR("IStorage -> IPropertySetStorage failed\n");
113 msiobj_release(&db
->hdr
);
114 return ERROR_FUNCTION_FAILED
;
116 ERR("storage = %p propertysetstorage = %p\n", db
->storage
, psstg
);
118 grfMode
= STGM_READ
| STGM_SHARE_EXCLUSIVE
;
119 r
= IPropertySetStorage_Open( psstg
, &FMTID_SummaryInformation
, grfMode
, &ps
);
122 ERR("failed to get IPropertyStorage r=%08lx\n",r
);
123 ret
= ERROR_FUNCTION_FAILED
;
127 suminfo
= alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO
,
128 sizeof (MSISUMMARYINFO
), MSI_CloseSummaryInfo
);
131 ret
= ERROR_FUNCTION_FAILED
;
135 IPropertyStorage_AddRef(ps
);
136 suminfo
->propstg
= ps
;
137 handle
= alloc_msihandle( &suminfo
->hdr
);
139 *phSummaryInfo
= handle
;
141 ret
= ERROR_FUNCTION_FAILED
;
142 msiobj_release( &suminfo
->hdr
);
146 IPropertyStorage_Release(ps
);
148 IPropertySetStorage_Release(psstg
);
150 msiobj_release(&db
->hdr
);
155 UINT WINAPI
MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo
, UINT
*pCount
)
157 MSISUMMARYINFO
*suminfo
;
159 FIXME("%ld %p\n",hSummaryInfo
, pCount
);
161 suminfo
= msihandle2msiinfo( hSummaryInfo
, MSIHANDLETYPE_SUMMARYINFO
);
163 return ERROR_INVALID_HANDLE
;
165 return ERROR_CALL_NOT_IMPLEMENTED
;
168 UINT WINAPI
MsiSummaryInfoGetPropertyA(
169 MSIHANDLE hSummaryInfo
, UINT uiProperty
, UINT
*puiDataType
, INT
*piValue
,
170 FILETIME
*pftValue
, LPSTR szValueBuf
, DWORD
*pcchValueBuf
)
172 MSISUMMARYINFO
*suminfo
;
177 TRACE("%ld %d %p %p %p %p %p\n",
178 hSummaryInfo
, uiProperty
, puiDataType
, piValue
,
179 pftValue
, szValueBuf
, pcchValueBuf
);
181 suminfo
= msihandle2msiinfo( hSummaryInfo
, MSIHANDLETYPE_SUMMARYINFO
);
183 return ERROR_INVALID_HANDLE
;
185 spec
.ulKind
= PRSPEC_PROPID
;
186 spec
.u
.propid
= uiProperty
;
188 r
= IPropertyStorage_ReadMultiple( suminfo
->propstg
, 1, &spec
, &var
);
190 return ERROR_FUNCTION_FAILED
;
193 *puiDataType
= var
.vt
;
199 *piValue
= var
.u
.lVal
;
202 if( pcchValueBuf
&& szValueBuf
)
204 lstrcpynA(szValueBuf
, var
.u
.pszVal
, *pcchValueBuf
);
205 *pcchValueBuf
= lstrlenA( var
.u
.pszVal
);
210 memcpy(pftValue
, &var
.u
.filetime
, sizeof (FILETIME
) );
215 FIXME("Unknown property variant type\n");
219 return ERROR_SUCCESS
;
222 UINT WINAPI
MsiSummaryInfoGetPropertyW(
223 MSIHANDLE hSummaryInfo
, UINT uiProperty
, UINT
*puiDataType
, INT
*piValue
,
224 FILETIME
*pftValue
, LPWSTR szValueBuf
, DWORD
*pcchValueBuf
)
226 FIXME("%ld %d %p %p %p %p %p\n",
227 hSummaryInfo
, uiProperty
, puiDataType
, piValue
,
228 pftValue
, szValueBuf
, pcchValueBuf
);
230 return ERROR_CALL_NOT_IMPLEMENTED
;