ReactOS 0.4.17-dev-970-gcf0f1a6
suminfo.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2005 Mike McCormack for CodeWeavers
3 *
4 * A test program for MSI database files.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#define COBJMACROS
22
23#include <stdio.h>
24#include <windows.h>
25#include <msi.h>
26#include <msiquery.h>
27#include <objidl.h>
28
29#include "wine/test.h"
30
31/*
32 * The following are defined in Windows SDK's msidefs.h
33 * but that file doesn't exist in the msvc6 header set.
34 *
35 * Some are already defined in PropIdl.h - undefine them
36 */
37#undef PID_DICTIONARY
38#undef PID_CODEPAGE
39#undef PID_SUBJECT
40#undef PID_SECURITY
41
42#define PID_DICTIONARY 0
43#define PID_CODEPAGE 1
44#define PID_TITLE 2
45#define PID_SUBJECT 3
46#define PID_AUTHOR 4
47#define PID_KEYWORDS 5
48#define PID_COMMENTS 6
49#define PID_TEMPLATE 7
50#define PID_LASTAUTHOR 8
51#define PID_REVNUMBER 9
52#define PID_EDITTINE 10
53#define PID_LASTPRINTED 11
54#define PID_CREATE_DTM 12
55#define PID_LASTSAVE_DTM 13
56#define PID_PAGECOUNT 14
57#define PID_WORDCOUNT 15
58#define PID_CHARCOUNT 16
59#define PID_THUMBNAIL 17
60#define PID_APPNAME 18
61#define PID_SECURITY 19
62#define PID_MSIVERSION PID_PAGECOUNT
63#define PID_MSISOURCE PID_WORDCOUNT
64#define PID_MSIRESTRICT PID_CHARCOUNT
65
66static const char *msifile = "winetest-suminfo.msi";
67static const WCHAR msifileW[] = L"winetest-suminfo.msi";
68
69static void test_suminfo(void)
70{
71 MSIHANDLE hdb = 0, hsuminfo;
72 UINT r, count, type;
73 DWORD sz;
74 INT val;
75 FILETIME ft;
76 char buf[0x10];
77
79
80 /* just MsiOpenDatabase should not create a file */
82 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
83
85 ok(r == ERROR_INVALID_PARAMETER, "MsiGetSummaryInformation wrong error\n");
86
87 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
88 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed %u\n", r);
89
90 r = MsiCloseHandle(hsuminfo);
91 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
92
93 r = MsiGetSummaryInformationA(0, "", 0, &hsuminfo);
96 "MsiGetSummaryInformation failed %u\n", r);
97
98 r = MsiGetSummaryInformationA(hdb, "", 0, &hsuminfo);
99 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed %u\n", r);
100
102 ok(r == ERROR_INVALID_HANDLE, "getpropcount failed\n");
103
105 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
106
107 count = -1;
109 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
110 ok(count == 0, "count should be zero\n");
111
112 r = MsiSummaryInfoGetPropertyA(hsuminfo, 0, NULL, NULL, NULL, 0, NULL);
113 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
114
115 r = MsiSummaryInfoGetPropertyA(hsuminfo, -1, NULL, NULL, NULL, 0, NULL);
116 ok(r == ERROR_UNKNOWN_PROPERTY, "MsiSummaryInfoGetProperty wrong error\n");
117
119 ok(r == ERROR_UNKNOWN_PROPERTY, "MsiSummaryInfoGetProperty wrong error\n");
120
121 type = -1;
122 r = MsiSummaryInfoGetPropertyA(hsuminfo, 0, &type, NULL, NULL, 0, NULL);
123 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
124 ok(type == 0, "wrong type\n");
125
126 type = -1;
127 val = 1234;
128 r = MsiSummaryInfoGetPropertyA(hsuminfo, 0, &type, &val, NULL, 0, NULL);
129 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
130 ok(type == 0, "wrong type\n");
131 ok(val == 1234, "wrong val\n");
132
133 buf[0]='x';
134 buf[1]=0;
135 sz = 0x10;
136 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_REVNUMBER, &type, &val, NULL, buf, &sz);
137 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
138 ok(buf[0]=='x', "cleared buffer\n");
139 ok(sz == 0x10, "count wasn't zero\n");
140 ok(type == VT_EMPTY, "should be empty\n");
141
142 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
143 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
144
145 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TITLE, VT_LPSTR, 1, NULL, "JungAh");
146 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
147
148 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TITLE, VT_LPSTR, 1, &ft, "Mike");
149 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
150
151 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "JungAh");
152 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
153
154 r = MsiCloseHandle(hsuminfo);
155 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
156
157 /* try again with the update count set */
158 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
159 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
160
161 r = MsiSummaryInfoSetPropertyA(hsuminfo, 0, VT_LPSTR, 1, NULL, NULL);
162 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
163
165 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
166
167 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TITLE, VT_I4, 0, NULL, "Mike");
168 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
169
170 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_I4, 0, NULL, "JungAh");
171 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
172
173 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_KEYWORDS, VT_I2, 0, NULL, "Mike");
174 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
175
176 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_COMMENTS, VT_FILETIME, 0, NULL, "JungAh");
177 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
178
179 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TEMPLATE, VT_I2, 0, NULL, "Mike");
180 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
181
183 ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");
184
186 ok(r == ERROR_INVALID_PARAMETER, "MsiSummaryInfoSetProperty wrong error\n");
187
188 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_LASTAUTHOR, VT_LPWSTR, 0, NULL, "h\0i\0\0");
189 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
190
191 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_REVNUMBER, VT_I4, 0, NULL, "Jungah");
192 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
193
195 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
196
197 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike");
198 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
199
200 sz = 2;
201 strcpy(buf,"x");
202 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz );
203 ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n");
204 ok(sz == 4, "count was wrong\n");
205 ok(type == VT_LPSTR, "type was wrong\n");
206 ok(!strcmp(buf,"M"), "buffer was wrong\n");
207
208 sz = 4;
209 strcpy(buf,"x");
210 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_TITLE, &type, NULL, NULL, buf, &sz );
211 ok(r == ERROR_MORE_DATA, "MsiSummaryInfoSetProperty failed\n");
212 ok(sz == 4, "count was wrong\n");
213 ok(type == VT_LPSTR, "type was wrong\n");
214 ok(!strcmp(buf,"Mik"), "buffer was wrong\n");
215
216 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
217 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
218
219 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
220 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error\n");
221
222 r = MsiCloseHandle(hsuminfo);
223 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
224
225 /* try again with a higher update count */
226 r = MsiGetSummaryInformationA(hdb, NULL, 10, &hsuminfo);
227 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
228
229 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "JungAh");
230 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty failed\n");
231
233 ok(r == ERROR_DATATYPE_MISMATCH, "MsiSummaryInfoSetProperty wrong error\n");
234
236 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
237
238 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_CODEPAGE, VT_I2, 1, &ft, "Mike");
239 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
240
241 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
242 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
243
244 r = MsiSummaryInfoPersist(hsuminfo);
245 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist failed\n");
246
248
249 r = MsiCloseHandle(hsuminfo);
250 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
251
252 r = MsiCloseHandle(hdb);
253 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
254
255 /* filename, non-zero update count */
256 r = MsiGetSummaryInformationA(0, msifile, 1, &hsuminfo);
257 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
258
259 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
260 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
261
262 r = MsiSummaryInfoPersist(hsuminfo);
263 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist failed %u\n", r);
264
265 r = MsiCloseHandle(hsuminfo);
266 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
267
268 /* filename, zero update count */
269 r = MsiGetSummaryInformationA(0, msifile, 0, &hsuminfo);
270 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed %u\n", r);
271
272 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Mike");
273 todo_wine ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty wrong error, %u\n", r);
274
275 r = MsiSummaryInfoPersist(hsuminfo);
276 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoPersist wrong error %u\n", r);
277
278 r = MsiCloseHandle(hsuminfo);
279 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
280
281 /* try persisting on transacted msi */
283 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
284
285 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
286 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n");
287
288 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian");
289 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
290
291 r = MsiSummaryInfoPersist(hsuminfo);
292 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r);
293
294 r = MsiCloseHandle(hsuminfo);
295 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
296
297 r = MsiCloseHandle(hdb);
298 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
299
301 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
302
303 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
304 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n");
305
306 sz = 0x10;
307 strcpy(buf,"x");
308 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz);
309 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n");
310 ok(!strcmp(buf,"Mike"), "buffer was wrong: %s\n", buf);
311
312 r = MsiCloseHandle(hsuminfo);
313 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
314
315 r = MsiCloseHandle(hdb);
316 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
317
318 /* try persisting on transacted msi with commit */
320 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
321
322 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
323 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n");
324
325 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian");
326 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
327
328 r = MsiSummaryInfoPersist(hsuminfo);
329 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r);
330
331 r = MsiCloseHandle(hsuminfo);
332 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
333
334 r = MsiDatabaseCommit(hdb);
335 ok(r == ERROR_SUCCESS, "MsiDatabaseCommit wrong error %u\n", r);
336
337 r = MsiCloseHandle(hdb);
338 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
339
341 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
342
343 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
344 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n");
345
346 sz = 0x10;
347 strcpy(buf,"x");
348 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz);
349 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n");
350 ok(!strcmp(buf,"Fabian"), "buffer was wrong: %s\n", buf);
351
352 r = MsiCloseHandle(hsuminfo);
353 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
354
355 r = MsiCloseHandle(hdb);
356 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
357
358 /* try persisting on direct msi */
360 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
361
362 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
363 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n");
364
365 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian2");
366 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
367
368 r = MsiSummaryInfoPersist(hsuminfo);
369 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r);
370
371 r = MsiCloseHandle(hsuminfo);
372 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
373
374 r = MsiCloseHandle(hdb);
375 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
376
378 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
379
380 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
381 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n");
382
383 sz = 0x10;
384 strcpy(buf,"x");
385 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz);
386 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n");
387 ok(!strcmp(buf,"Fabian2"), "buffer was wrong: %s\n", buf);
388
389 r = MsiCloseHandle(hsuminfo);
390 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
391
392 r = MsiCloseHandle(hdb);
393 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
394
395 /* try persisting on indirectly opened msi */
396 r = MsiGetSummaryInformationA(0, msifile, 2, &hsuminfo);
397 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error %u\n", r);
398
399 r = MsiSummaryInfoSetPropertyA(hsuminfo, PID_AUTHOR, VT_LPSTR, 1, &ft, "Fabian3");
400 ok(r == ERROR_SUCCESS, "MsiSummaryInfoSetProperty wrong error\n");
401
402 r = MsiSummaryInfoPersist(hsuminfo);
403 ok(r == ERROR_SUCCESS, "MsiSummaryInfoPersist wrong error %u\n", r);
404
405 r = MsiCloseHandle(hsuminfo);
406 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
407
409 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
410
411 r = MsiGetSummaryInformationA(hdb, NULL, 1, &hsuminfo);
412 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation wrong error\n");
413
414 sz = 0x10;
415 strcpy(buf,"x");
416 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_AUTHOR, &type, NULL, NULL, buf, &sz);
417 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetPropertyA wrong error\n");
418 ok(!strcmp(buf,"Fabian3"), "buffer was wrong: %s\n", buf);
419
420 r = MsiCloseHandle(hsuminfo);
421 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
422
423 r = MsiCloseHandle(hdb);
424 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed\n");
425
426 /* Cleanup */
428 ok(r, "DeleteFile failed\n");
429}
430
431static const WCHAR tb[] = { 0x4840, 0x3f7f, 0x4164, 0x422f, 0x4836, 0 }; /* _Tables */
432static const WCHAR sd[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */
433static const WCHAR sp[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */
434
435#define LOSE_CONST(x) ((LPSTR)(UINT_PTR)(x))
436
438{
439 static const CLSID CLSID_MsiDatabase =
440 { 0xc1084, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
441 static const CLSID IID_IPropertySetStorage =
442 { 0x13a, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46 } };
443 static const CLSID FMTID_SummaryInformation =
444 { 0xf29f85e0, 0x4ff9, 0x1068, {0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9}};
448 IStorage *stg = NULL;
449 IStream *stm = NULL;
450 HRESULT r;
451 PROPSPEC propspec[10];
452 PROPVARIANT propvar[10];
453 USHORT data[2] = { 0, 0 };
454
455 r = StgCreateDocfile( msifileW, mode, 0, &stg );
456 ok( r == S_OK, "failed to create database\n");
457
458 r = IStorage_SetClass( stg, &CLSID_MsiDatabase );
459 ok( r == S_OK, "failed to set clsid\n");
460
461 /* create the _StringData stream */
462 r = IStorage_CreateStream( stg, sd, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
463 ok( r == S_OK, "failed to create stream\n");
464
465 IStream_Release( stm );
466
467 /* create the _StringPool stream */
468 r = IStorage_CreateStream( stg, sp, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
469 ok( r == S_OK, "failed to create stream\n");
470
471 r = IStream_Write( stm, data, sizeof data, NULL );
472 ok( r == S_OK, "failed to write stream\n");
473
474 IStream_Release( stm );
475
476 /* create the _Tables stream */
477 r = IStorage_CreateStream( stg, tb, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm );
478 ok( r == S_OK, "failed to create stream\n");
479
480 IStream_Release( stm );
481
482 r = IStorage_QueryInterface( stg, &IID_IPropertySetStorage, (void**) &pss );
483 ok( r == S_OK, "failed to set clsid\n");
484
485 r = IPropertySetStorage_Create( pss, &FMTID_SummaryInformation, NULL, 0, mode, &ps );
486 ok( r == S_OK, "failed to create property set\n");
487
488 r = IPropertyStorage_SetClass( ps, &FMTID_SummaryInformation );
489 ok( r == S_OK, "failed to set class\n");
490
491 propspec[0].ulKind = PRSPEC_PROPID;
492 propspec[0].propid = PID_TITLE;
493 propvar[0].vt = VT_LPSTR;
494 propvar[0].pszVal = LOSE_CONST("test title");
495
496 propspec[1].ulKind = PRSPEC_PROPID;
497 propspec[1].propid = PID_SUBJECT;
498 propvar[1].vt = VT_LPSTR;
499 propvar[1].pszVal = LOSE_CONST("msi suminfo / property storage test");
500
501 propspec[2].ulKind = PRSPEC_PROPID;
502 propspec[2].propid = PID_AUTHOR;
503 propvar[2].vt = VT_LPSTR;
504 propvar[2].pszVal = LOSE_CONST("mike_m");
505
506 propspec[3].ulKind = PRSPEC_PROPID;
507 propspec[3].propid = PID_TEMPLATE;
508 propvar[3].vt = VT_LPSTR;
509 propvar[3].pszVal = LOSE_CONST(";1033"); /* actually the string table's codepage */
510
511 propspec[4].ulKind = PRSPEC_PROPID;
512 propspec[4].propid = PID_REVNUMBER;
513 propvar[4].vt = VT_LPSTR;
514 propvar[4].pszVal = LOSE_CONST("{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
515
516 propspec[5].ulKind = PRSPEC_PROPID;
517 propspec[5].propid = PID_PAGECOUNT;
518 propvar[5].vt = VT_I4;
519 propvar[5].lVal = 100;
520
521 propspec[6].ulKind = PRSPEC_PROPID;
522 propspec[6].propid = PID_WORDCOUNT;
523 propvar[6].vt = VT_I4;
524 propvar[6].lVal = 0;
525
526 /* MSDN says that PID_LASTPRINTED should be a VT_FILETIME... */
527 propspec[7].ulKind = PRSPEC_PROPID;
528 propspec[7].propid = PID_LASTPRINTED;
529 propvar[7].vt = VT_LPSTR;
530 propvar[7].pszVal = LOSE_CONST("7/1/1999 5:17");
531
532 r = IPropertyStorage_WriteMultiple( ps, 8, propspec, propvar, PID_FIRST_USABLE );
533 ok( r == S_OK, "failed to write properties\n");
534
535 IPropertyStorage_Commit( ps, STGC_DEFAULT );
536
537 IPropertyStorage_Release( ps );
538 IPropertySetStorage_Release( pss );
539
540 IStorage_Commit( stg, STGC_DEFAULT );
541 IStorage_Release( stg );
542}
543
544static void test_summary_binary(void)
545{
546 MSIHANDLE hdb = 0, hsuminfo = 0;
547 UINT r, type, count;
548 INT ival;
549 DWORD sz;
550 char sval[20];
551
553
555
556 ok(GetFileAttributesA(msifile) != INVALID_FILE_ATTRIBUTES, "file doesn't exist!\n");
557
558 /* just MsiOpenDatabase should not create a file */
560 ok(r == ERROR_SUCCESS, "MsiOpenDatabase failed\n");
561
562 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
563 ok(r == ERROR_SUCCESS, "MsiGetSummaryInformation failed\n");
564
565 /*
566 * Check what reading PID_LASTPRINTED does...
567 * The string value is written to the msi file
568 * but it appears that we're not allowed to read it back again.
569 * We can still read its type though...?
570 */
571 sz = sizeof sval;
572 sval[0] = 0;
573 type = 0;
574 r = MsiSummaryInfoGetPropertyA(hsuminfo, PID_LASTPRINTED, &type, NULL, NULL, sval, &sz);
575 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetProperty failed\n");
576 ok(!lstrcmpA(sval, "") || !lstrcmpA(sval, "7"),
577 "Expected empty string or \"7\", got \"%s\"\n", sval);
578 todo_wine {
579 ok(type == VT_LPSTR, "Expected VT_LPSTR, got %d\n", type);
580 ok(sz == 0 || sz == 1, "Expected 0 or 1, got %lu\n", sz);
581 }
582
583 ival = -1;
585 ok(r == ERROR_SUCCESS, "MsiSummaryInfoGetProperty failed\n");
586 todo_wine ok( ival == 0, "value incorrect\n");
587
588 /* looks like msi adds some of its own values in here */
589 count = 0;
590 r = MsiSummaryInfoGetPropertyCount( hsuminfo, &count );
591 ok(r == ERROR_SUCCESS, "getpropcount failed\n");
592 todo_wine ok(count == 10, "prop count incorrect\n");
593
594 r = MsiSummaryInfoSetPropertyA( hsuminfo, PID_TITLE, VT_LPSTR, 0, NULL, "Mike" );
595 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoSetProperty failed %u\n", r);
596
597 r = MsiSummaryInfoPersist( hsuminfo );
598 ok(r == ERROR_FUNCTION_FAILED, "MsiSummaryInfoPersist failed %u\n", r);
599
600 MsiCloseHandle( hsuminfo );
601 MsiCloseHandle( hdb );
602
604}
605
607{
608 test_suminfo();
610}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
static const CHAR suminfo[]
Definition: db.c:2166
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
@ VT_LPSTR
Definition: compat.h:2324
@ VT_LPWSTR
Definition: compat.h:2325
@ VT_I4
Definition: compat.h:2298
@ VT_FILETIME
Definition: compat.h:2329
@ VT_I2
Definition: compat.h:2297
@ VT_EMPTY
Definition: compat.h:2295
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:620
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4104
UINT WINAPI MsiOpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIHANDLE *phDB)
Definition: database.c:298
UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
Definition: handle.c:269
UINT WINAPI MsiSummaryInfoSetPropertyA(MSIHANDLE handle, UINT uiProperty, UINT uiDataType, INT iValue, FILETIME *pftValue, const char *szValue)
Definition: suminfo.c:941
UINT WINAPI MsiSummaryInfoGetPropertyA(MSIHANDLE handle, UINT uiProperty, UINT *puiDataType, INT *piValue, FILETIME *pftValue, char *szValueBuf, DWORD *pcchValueBuf)
Definition: suminfo.c:741
UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase, const char *szDatabase, UINT uiUpdateCount, MSIHANDLE *pHandle)
Definition: suminfo.c:588
UINT WINAPI MsiSummaryInfoGetPropertyCount(MSIHANDLE hSummaryInfo, UINT *pCount)
Definition: suminfo.c:610
UINT WINAPI MsiSummaryInfoPersist(MSIHANDLE handle)
Definition: suminfo.c:1226
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8597
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum mode
Definition: glext.h:6217
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLfloat * val
Definition: glext.h:7180
unsigned int UINT
Definition: sysinfo.c:13
#define S_OK
Definition: intsafe.h:52
#define todo_wine
Definition: minitest.h:80
static const WCHAR tb[]
Definition: suminfo.c:431
#define PID_TEMPLATE
Definition: suminfo.c:49
static const WCHAR msifileW[]
Definition: suminfo.c:67
#define PID_KEYWORDS
Definition: suminfo.c:47
#define LOSE_CONST(x)
Definition: suminfo.c:435
static void test_summary_binary(void)
Definition: suminfo.c:544
static void test_suminfo(void)
Definition: suminfo.c:69
#define PID_PAGECOUNT
Definition: suminfo.c:56
static void test_create_database_binary(void)
Definition: suminfo.c:437
#define PID_WORDCOUNT
Definition: suminfo.c:57
#define PID_SECURITY
Definition: suminfo.c:61
static const WCHAR sd[]
Definition: suminfo.c:432
#define PID_COMMENTS
Definition: suminfo.c:48
#define PID_TITLE
Definition: suminfo.c:44
static const char * msifile
Definition: suminfo.c:66
#define PID_LASTAUTHOR
Definition: suminfo.c:50
#define PID_AUTHOR
Definition: suminfo.c:46
#define PID_REVNUMBER
Definition: suminfo.c:51
#define PID_LASTPRINTED
Definition: suminfo.c:53
static const WCHAR sp[]
Definition: suminfo.c:433
#define PID_SUBJECT
Definition: suminfo.c:45
#define PID_CODEPAGE
Definition: suminfo.c:43
#define PID_LASTSAVE_DTM
Definition: suminfo.c:55
UINT WINAPI MsiDatabaseCommit(MSIHANDLE hdb)
Definition: msiquery.c:958
#define MSIDBOPEN_DIRECT
Definition: msiquery.h:68
#define MSIDBOPEN_CREATE
Definition: msiquery.h:69
#define MSIDBOPEN_TRANSACT
Definition: msiquery.h:67
#define MSIDBOPEN_READONLY
Definition: msiquery.h:66
#define STGM_CREATE
Definition: objbase.h:945
#define STGM_DIRECT
Definition: objbase.h:933
#define STGM_READWRITE
Definition: objbase.h:938
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:942
#define STGM_WRITE
Definition: objbase.h:937
const FMTID FMTID_SummaryInformation
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
#define PID_FIRST_USABLE
Definition: propkeydef.h:20
strcpy
Definition: string.h:131
int32_t INT
Definition: typedefs.h:58
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
unsigned long MSIHANDLE
Definition: winemsi.idl:27
#define ERROR_INSTALL_PACKAGE_INVALID
Definition: winerror.h:1326
#define ERROR_INSTALL_PACKAGE_OPEN_FAILED
Definition: winerror.h:1325
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:1333
#define ERROR_UNKNOWN_PROPERTY
Definition: winerror.h:1314
#define ERROR_DATATYPE_MISMATCH
Definition: winerror.h:1335