1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
/* IPropertyStorage unit tests
* Copyright 2005 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdio.h>
#define COBJMACROS
#include "objbase.h"
#include "wine/test.h"
#include "initguid.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
DEFINE_GUID(FMTID_SummaryInformation,0xF29F85E0,0x4FF9,0x1068,0xAB,0x91,0x08,0x00,0x2B,0x27,0xB3,0xD9);
DEFINE_GUID(FMTID_DocSummaryInformation,0xD5CDD502,0x2E9C,0x101B,0x93,0x97,0x08,0x00,0x2B,0x2C,0xF9,0xAE);
DEFINE_GUID(FMTID_UserDefinedProperties,0xD5CDD505,0x2E9C,0x101B,0x93,0x97,0x08,0x00,0x2B,0x2C,0xF9,0xAE);
#ifndef PID_BEHAVIOR
#define PID_BEHAVIOR 0x80000003
#endif
static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
static void init_function_pointers(void)
{
HMODULE hmod = GetModuleHandleA("ole32.dll");
pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
}
/* FIXME: this creates an ANSI storage, try to find conditions under which
* Unicode translation fails
*/
static void testProps(void)
{
static const WCHAR szDot[] = { '.',0 };
static const WCHAR szPrefix[] = { 's','t','g',0 };
static WCHAR propName[] = { 'p','r','o','p',0 };
static char val[] = "l33t auth0r";
WCHAR filename[MAX_PATH];
HRESULT hr;
IStorage *storage = NULL;
IPropertySetStorage *propSetStorage = NULL;
IPropertyStorage *propertyStorage = NULL;
PROPSPEC spec;
PROPVARIANT var;
CLIPDATA clipdata;
unsigned char clipcontent[] = "foobar";
if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
return;
DeleteFileW(filename);
hr = StgCreateDocfile(filename,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
if(!pStgCreatePropSetStg)
{
IStorage_Release(storage);
DeleteFileW(filename);
return;
}
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Create(propSetStorage,
&FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
&propertyStorage);
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
ok(hr == S_OK, "WriteMultiple with 0 args failed: 0x%08x\n", hr);
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, NULL, NULL, 0);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
/* test setting one that I can't set */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_DICTIONARY;
var.vt = VT_I4;
U(var).lVal = 1;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == STG_E_INVALIDPARAMETER,
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
/* test setting one by name with an invalid propidNameFirst */
spec.ulKind = PRSPEC_LPWSTR;
U(spec).lpwstr = propName;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
PID_DICTIONARY);
ok(hr == STG_E_INVALIDPARAMETER,
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
/* test setting behavior (case-sensitive) */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_BEHAVIOR;
U(var).lVal = 1;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == STG_E_INVALIDPARAMETER,
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
/* set one by value.. */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_FIRST_USABLE;
U(var).lVal = 1;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* set one by name */
spec.ulKind = PRSPEC_LPWSTR;
U(spec).lpwstr = propName;
U(var).lVal = 2;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
PID_FIRST_USABLE);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* set a string value */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PIDSI_AUTHOR;
var.vt = VT_LPSTR;
U(var).pszVal = val;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* set a clipboard value */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PIDSI_THUMBNAIL;
var.vt = VT_CF;
clipdata.cbSize = sizeof clipcontent + sizeof (ULONG);
clipdata.ulClipFmt = CF_ENHMETAFILE;
clipdata.pClipData = clipcontent;
U(var).pclipdata = &clipdata;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* check reading */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 0, NULL, NULL);
ok(hr == S_FALSE, "ReadMultiple with 0 args failed: 0x%08x\n", hr);
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, NULL, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
/* read by propid */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_FIRST_USABLE;
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I4 && U(var).lVal == 1,
"Didn't get expected type or value for property (got type %d, value %d)\n",
var.vt, U(var).lVal);
/* read by name */
spec.ulKind = PRSPEC_LPWSTR;
U(spec).lpwstr = propName;
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I4 && U(var).lVal == 2,
"Didn't get expected type or value for property (got type %d, value %d)\n",
var.vt, U(var).lVal);
/* read string value */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PIDSI_AUTHOR;
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
"Didn't get expected type or value for property (got type %d, value %s)\n",
var.vt, U(var).pszVal);
/* read clipboard format */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PIDSI_THUMBNAIL;
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_CF, "variant type wrong\n");
ok(U(var).pclipdata->ulClipFmt == CF_ENHMETAFILE,
"clipboard type wrong\n");
ok(U(var).pclipdata->cbSize == sizeof clipcontent + sizeof (ULONG),
"clipboard size wrong\n");
ok(!memcmp(U(var).pclipdata->pClipData, clipcontent, sizeof clipcontent),
"clipboard contents wrong\n");
ok(S_OK == PropVariantClear(&var), "failed to clear variant\n");
/* check deleting */
hr = IPropertyStorage_DeleteMultiple(propertyStorage, 0, NULL);
ok(hr == S_OK, "DeleteMultiple with 0 args failed: 0x%08x\n", hr);
hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
/* contrary to what the docs say, you can't delete the dictionary */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_DICTIONARY;
hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
ok(hr == STG_E_INVALIDPARAMETER,
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
/* now delete the first value.. */
U(spec).propid = PID_FIRST_USABLE;
hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
ok(hr == S_OK, "DeleteMultiple failed: 0x%08x\n", hr);
/* and check that it's no longer readable */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08x\n", hr);
hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
/* check reverting */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_FIRST_USABLE;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
hr = IPropertyStorage_Revert(propertyStorage);
ok(hr == S_OK, "Revert failed: 0x%08x\n", hr);
/* now check that it's still not there */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08x\n", hr);
/* set an integer value again */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_FIRST_USABLE;
var.vt = VT_I4;
U(var).lVal = 1;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* commit it */
hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
/* set it to a string value */
var.vt = VT_LPSTR;
U(var).pszVal = val;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* revert it */
hr = IPropertyStorage_Revert(propertyStorage);
ok(hr == S_OK, "Revert failed: 0x%08x\n", hr);
/* Oddly enough, there's no guarantee that a successful revert actually
* implies the value wasn't saved. Maybe transactional mode needs to be
* used for that?
*/
IPropertyStorage_Release(propertyStorage);
propertyStorage = NULL;
IPropertySetStorage_Release(propSetStorage);
propSetStorage = NULL;
IStorage_Release(storage);
storage = NULL;
/* now open it again */
hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
NULL, 0, &storage);
ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
/* check properties again */
spec.ulKind = PRSPEC_LPWSTR;
U(spec).lpwstr = propName;
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I4 && U(var).lVal == 2,
"Didn't get expected type or value for property (got type %d, value %d)\n",
var.vt, U(var).lVal);
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PIDSI_AUTHOR;
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
"Didn't get expected type or value for property (got type %d, value %s)\n",
var.vt, U(var).pszVal);
IPropertyStorage_Release(propertyStorage);
IPropertySetStorage_Release(propSetStorage);
IStorage_Release(storage);
DeleteFileW(filename);
}
static void testCodepage(void)
{
static const WCHAR szDot[] = { '.',0 };
static const WCHAR szPrefix[] = { 's','t','g',0 };
static CHAR aval[] = "hi";
static WCHAR wval[] = { 'h','i',0 };
HRESULT hr;
IStorage *storage = NULL;
IPropertySetStorage *propSetStorage = NULL;
IPropertyStorage *propertyStorage = NULL;
PROPSPEC spec;
PROPVARIANT var;
WCHAR fileName[MAX_PATH];
if(!GetTempFileNameW(szDot, szPrefix, 0, fileName))
return;
hr = StgCreateDocfile(fileName,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
if(!pStgCreatePropSetStg)
{
IStorage_Release(storage);
DeleteFileW(fileName);
return;
}
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Create(propSetStorage,
&FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
&propertyStorage);
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
PropVariantInit(&var);
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_CODEPAGE;
/* check code page before it's been explicitly set */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I2 && U(var).iVal == 1200,
"Didn't get expected type or value for property\n");
/* Set the code page to ascii */
var.vt = VT_I2;
U(var).iVal = 1252;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* check code page */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I2 && U(var).iVal == 1252,
"Didn't get expected type or value for property\n");
/* Set code page to Unicode */
U(var).iVal = 1200;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* check code page */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I2 && U(var).iVal == 1200,
"Didn't get expected type or value for property\n");
/* Set a string value */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_FIRST_USABLE;
var.vt = VT_LPSTR;
U(var).pszVal = aval;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "hi"),
"Didn't get expected type or value for property\n");
/* This seemingly non-sensical test is to show that the string is indeed
* interpreted according to the current system code page, not according to
* the property set's code page. (If the latter were true, the whole
* string would be maintained. As it is, only the first character is.)
*/
U(var).pszVal = (LPSTR)wval;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "h"),
"Didn't get expected type or value for property\n");
/* now that a property's been set, you can't change the code page */
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_CODEPAGE;
var.vt = VT_I2;
U(var).iVal = 1200;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == STG_E_INVALIDPARAMETER,
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
IPropertyStorage_Release(propertyStorage);
IPropertySetStorage_Release(propSetStorage);
IStorage_Release(storage);
DeleteFileW(fileName);
/* same tests, but with PROPSETFLAG_ANSI */
hr = StgCreateDocfile(fileName,
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Create(propSetStorage,
&FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
&propertyStorage);
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
/* check code page before it's been explicitly set */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I2, "Didn't get expected type for property (%u)\n", var.vt);
/* Set code page to Unicode */
U(var).iVal = 1200;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* check code page */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_I2 && U(var).iVal == 1200,
"Didn't get expected type or value for property\n");
/* This test is commented out for documentation. It fails under Wine,
* and I expect it would under Windows as well, yet it succeeds. There's
* obviously something about string conversion I don't understand.
*/
if(0) {
static unsigned char strVal[] = { 0x81, 0xff, 0x04, 0 };
/* Set code page to 950 (Traditional Chinese) */
U(var).iVal = 950;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* Try writing an invalid string: lead byte 0x81 is unused in Traditional
* Chinese.
*/
spec.ulKind = PRSPEC_PROPID;
U(spec).propid = PID_FIRST_USABLE;
var.vt = VT_LPSTR;
U(var).pszVal = (LPSTR)strVal;
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
/* Check returned string */
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, (LPCSTR)strVal),
"Didn't get expected type or value for property\n");
}
IPropertyStorage_Release(propertyStorage);
IPropertySetStorage_Release(propSetStorage);
IStorage_Release(storage);
DeleteFileW(fileName);
}
static void testFmtId(void)
{
WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
'I','n','f','o','r','m','a','t','i','o','n',0 };
WCHAR szDocSummaryInfo[] = { 5,'D','o','c','u','m','e','n','t',
'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
0 };
WCHAR szIID_IPropSetStg[] = { 5,'0','j','a','a','a','a','a',
'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
'c',0 };
WCHAR name[32];
FMTID fmtid;
HRESULT hr;
if (pFmtIdToPropStgName) {
hr = pFmtIdToPropStgName(NULL, name);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name);
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) *
sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n");
hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name);
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name);
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name);
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) *
sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n");
}
if(pPropStgNameToFmtId) {
/* test args first */
hr = pPropStgNameToFmtId(NULL, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
hr = pPropStgNameToFmtId(NULL, &fmtid);
ok(hr == STG_E_INVALIDNAME, "Expected STG_E_INVALIDNAME, got 0x%08x\n",
hr);
hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
/* test the known format IDs */
hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid);
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)),
"Got unexpected FMTID, expected FMTID_SummaryInformation\n");
hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
"Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
/* test another GUID */
hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
"Got unexpected FMTID, expected IID_IPropertySetStorage\n");
/* now check case matching */
CharUpperW(szDocSummaryInfo + 1);
hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
"Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
CharUpperW(szIID_IPropSetStg + 1);
hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
"Got unexpected FMTID, expected IID_IPropertySetStorage\n");
}
}
START_TEST(stg_prop)
{
init_function_pointers();
testProps();
testCodepage();
testFmtId();
}