Don't define COBJMACROS in objbase.h.
[wine/multimedia.git] / dlls / msi / suminfo.c
blobcecd37ab3489177b25a1c3b25a63563a29c0ec3f
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 #include <stdarg.h>
23 #define COBJMACROS
24 #define NONAMELESSUNION
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 "msipriv.h"
35 #include "objidl.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;
52 UINT ret;
54 TRACE("%ld %s %d %p\n", hDatabase, debugstr_a(szDatabase),
55 uiUpdateCount, phSummaryInfo);
57 if( szDatabase )
59 UINT len = MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, NULL, 0 );
60 szwDatabase = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
61 if( !szwDatabase )
62 return ERROR_FUNCTION_FAILED;
63 MultiByteToWideChar( CP_ACP, 0, szDatabase, -1, szwDatabase, len );
66 ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, phSummaryInfo);
68 if( szwDatabase )
69 HeapFree( GetProcessHeap(), 0, szwDatabase );
71 return ret;
74 UINT WINAPI MsiGetSummaryInformationW(MSIHANDLE hDatabase,
75 LPCWSTR szDatabase, UINT uiUpdateCount, MSIHANDLE *phSummaryInfo)
77 HRESULT r;
78 MSIHANDLE handle;
79 MSISUMMARYINFO *suminfo;
80 MSIDATABASE *db;
81 UINT ret = ERROR_SUCCESS;
82 IPropertySetStorage *psstg = NULL;
83 IPropertyStorage *ps = NULL;
84 DWORD grfMode;
86 TRACE("%ld %s %d %p\n", hDatabase, debugstr_w(szDatabase),
87 uiUpdateCount, phSummaryInfo);
89 if( !phSummaryInfo )
90 return ERROR_INVALID_PARAMETER;
92 if( szDatabase )
94 UINT res;
96 res = MSI_OpenDatabaseW(szDatabase, NULL, &db);
97 if( res != ERROR_SUCCESS )
98 return res;
100 else
102 db = msihandle2msiinfo(hDatabase, MSIHANDLETYPE_DATABASE);
103 if( !db )
104 return ERROR_INVALID_PARAMETER;
107 r = IStorage_QueryInterface( db->storage,
108 &IID_IPropertySetStorage, (LPVOID)&psstg);
109 if( FAILED( r ) )
111 ERR("IStorage -> IPropertySetStorage failed\n");
112 if (db)
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 );
120 if( FAILED( r ) )
122 ERR("failed to get IPropertyStorage r=%08lx\n",r);
123 ret = ERROR_FUNCTION_FAILED;
124 goto end;
127 suminfo = alloc_msiobject( MSIHANDLETYPE_SUMMARYINFO,
128 sizeof (MSISUMMARYINFO), MSI_CloseSummaryInfo );
129 if( !suminfo )
131 ret = ERROR_FUNCTION_FAILED;
132 goto end;
135 IPropertyStorage_AddRef(ps);
136 suminfo->propstg = ps;
137 handle = alloc_msihandle( &suminfo->hdr );
138 if( handle )
139 *phSummaryInfo = handle;
140 else
141 ret = ERROR_FUNCTION_FAILED;
142 msiobj_release( &suminfo->hdr );
144 end:
145 if( ps )
146 IPropertyStorage_Release(ps);
147 if( psstg )
148 IPropertySetStorage_Release(psstg);
149 if (db)
150 msiobj_release(&db->hdr);
152 return ret;
155 UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
157 MSISUMMARYINFO *suminfo;
159 FIXME("%ld %p\n",hSummaryInfo, pCount);
161 suminfo = msihandle2msiinfo( hSummaryInfo, MSIHANDLETYPE_SUMMARYINFO );
162 if( !suminfo )
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;
173 HRESULT r;
174 PROPSPEC spec;
175 PROPVARIANT var;
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 );
182 if( !suminfo )
183 return ERROR_INVALID_HANDLE;
185 spec.ulKind = PRSPEC_PROPID;
186 spec.u.propid = uiProperty;
188 r = IPropertyStorage_ReadMultiple( suminfo->propstg, 1, &spec, &var);
189 if( FAILED(r) )
190 return ERROR_FUNCTION_FAILED;
192 if( puiDataType )
193 *puiDataType = var.vt;
195 switch( var.vt )
197 case VT_I4:
198 if( piValue )
199 *piValue = var.u.lVal;
200 break;
201 case VT_LPSTR:
202 if( pcchValueBuf && szValueBuf )
204 lstrcpynA(szValueBuf, var.u.pszVal, *pcchValueBuf );
205 *pcchValueBuf = lstrlenA( var.u.pszVal );
207 break;
208 case VT_FILETIME:
209 if( pftValue )
210 memcpy(pftValue, &var.u.filetime, sizeof (FILETIME) );
211 break;
212 case VT_EMPTY:
213 break;
214 default:
215 FIXME("Unknown property variant type\n");
216 break;
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;