1 /* IPropertyStorage unit tests
2 * Copyright 2005 Juan Lang
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/test.h"
23 static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
24 static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
25 static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
27 static void init_function_pointers(void)
29 HMODULE hmod = GetModuleHandleA("ole32.dll");
33 pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
34 pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
35 pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
38 /* FIXME: this creates an ANSI storage, try to find conditions under which
39 * Unicode translation fails
41 static void testProps(void)
43 static const WCHAR szDot[] = { '.',0 };
44 static const WCHAR szPrefix[] = { 's','t','g',0 };
45 static const WCHAR propName[] = { 'p','r','o','p',0 };
46 static const char val[] = "l33t auth0r";
47 WCHAR filename[MAX_PATH];
49 IStorage *storage = NULL;
50 IPropertySetStorage *propSetStorage = NULL;
51 IPropertyStorage *propertyStorage = NULL;
55 if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
58 DeleteFileW(filename);
60 hr = StgCreateDocfile(filename,
61 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
62 ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr);
64 if(!pStgCreatePropSetStg)
66 IStorage_Release(storage);
67 DeleteFileW(filename);
70 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
71 ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
73 hr = IPropertySetStorage_Create(propSetStorage,
74 &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
75 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
77 ok(SUCCEEDED(hr), "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
79 hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
80 ok(SUCCEEDED(hr), "WriteMultiple with 0 args failed: 0x%08lx\n", hr);
81 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, NULL, NULL, 0);
82 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
84 /* test setting one that I can't set */
85 spec.ulKind = PRSPEC_PROPID;
86 U(spec).propid = PID_DICTIONARY;
87 PropVariantClear(&var);
90 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
91 ok(hr == STG_E_INVALIDPARAMETER,
92 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
94 /* test setting one by name with an invalid propidNameFirst */
95 spec.ulKind = PRSPEC_LPWSTR;
96 U(spec).lpwstr = (LPOLESTR)propName;
97 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
99 ok(hr == STG_E_INVALIDPARAMETER,
100 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
102 /* test setting behavior (case-sensitive) */
103 spec.ulKind = PRSPEC_PROPID;
104 U(spec).propid = PID_BEHAVIOR;
106 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
107 ok(hr == STG_E_INVALIDPARAMETER,
108 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
110 /* set one by value.. */
111 spec.ulKind = PRSPEC_PROPID;
112 U(spec).propid = PID_FIRST_USABLE;
114 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
115 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
117 /* set one by name */
118 spec.ulKind = PRSPEC_LPWSTR;
119 U(spec).lpwstr = (LPOLESTR)propName;
121 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
123 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
125 /* set a string value */
126 spec.ulKind = PRSPEC_PROPID;
127 U(spec).propid = PIDSI_AUTHOR;
129 U(var).pszVal = (LPSTR)val;
130 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
131 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
134 hr = IPropertyStorage_ReadMultiple(propertyStorage, 0, NULL, NULL);
135 ok(SUCCEEDED(hr), "ReadMultiple with 0 args failed: 0x%08lx\n", hr);
136 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, NULL, NULL);
137 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
139 spec.ulKind = PRSPEC_PROPID;
140 U(spec).propid = PID_FIRST_USABLE;
141 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
142 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
143 ok(var.vt == VT_I4 && U(var).lVal == 1,
144 "Didn't get expected type or value for property (got type %d, value %ld)\n",
145 var.vt, U(var).lVal);
147 spec.ulKind = PRSPEC_LPWSTR;
148 U(spec).lpwstr = (LPOLESTR)propName;
149 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
150 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
151 ok(var.vt == VT_I4 && U(var).lVal == 2,
152 "Didn't get expected type or value for property (got type %d, value %ld)\n",
153 var.vt, U(var).lVal);
154 /* read string value */
155 spec.ulKind = PRSPEC_PROPID;
156 U(spec).propid = PIDSI_AUTHOR;
157 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
158 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
159 ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
160 "Didn't get expected type or value for property (got type %d, value %s)\n",
161 var.vt, U(var).pszVal);
164 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 0, NULL);
165 ok(SUCCEEDED(hr), "DeleteMultiple with 0 args failed: 0x%08lx\n", hr);
166 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, NULL);
167 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
168 /* contrary to what the docs say, you can't delete the dictionary */
169 spec.ulKind = PRSPEC_PROPID;
170 U(spec).propid = PID_DICTIONARY;
171 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
172 ok(hr == STG_E_INVALIDPARAMETER,
173 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
174 /* now delete the first value.. */
175 U(spec).propid = PID_FIRST_USABLE;
176 hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
177 ok(SUCCEEDED(hr), "DeleteMultiple failed: 0x%08lx\n", hr);
178 /* and check that it's no longer readable */
179 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
180 ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08lx\n", hr);
182 hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
183 ok(SUCCEEDED(hr), "Commit failed: 0x%08lx\n", hr);
185 /* check reverting */
186 spec.ulKind = PRSPEC_PROPID;
187 U(spec).propid = PID_FIRST_USABLE;
188 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
189 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
190 hr = IPropertyStorage_Revert(propertyStorage);
191 ok(SUCCEEDED(hr), "Revert failed: 0x%08lx\n", hr);
192 /* now check that it's still not there */
193 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
194 ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08lx\n", hr);
195 /* set an integer value again */
196 spec.ulKind = PRSPEC_PROPID;
197 U(spec).propid = PID_FIRST_USABLE;
200 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
201 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
203 hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
204 ok(SUCCEEDED(hr), "Commit failed: 0x%08lx\n", hr);
205 /* set it to a string value */
207 U(var).pszVal = (LPSTR)val;
208 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
209 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
211 hr = IPropertyStorage_Revert(propertyStorage);
212 ok(SUCCEEDED(hr), "Revert failed: 0x%08lx\n", hr);
213 /* Oddly enough, there's no guarantee that a successful revert actually
214 * implies the value wasn't saved. Maybe transactional mode needs to be
218 IPropertyStorage_Release(propertyStorage);
219 propertyStorage = NULL;
220 IPropertySetStorage_Release(propSetStorage);
221 propSetStorage = NULL;
222 IStorage_Release(storage);
225 /* now open it again */
226 hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
228 ok(SUCCEEDED(hr), "StgOpenStorage failed: 0x%08lx\n", hr);
230 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
231 ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
233 hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation,
234 STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
235 ok(SUCCEEDED(hr), "IPropertySetStorage_Open failed: 0x%08lx\n", hr);
237 /* check properties again */
238 spec.ulKind = PRSPEC_LPWSTR;
239 U(spec).lpwstr = (LPOLESTR)propName;
240 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
241 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
242 ok(var.vt == VT_I4 && U(var).lVal == 2,
243 "Didn't get expected type or value for property (got type %d, value %ld)\n",
244 var.vt, U(var).lVal);
245 spec.ulKind = PRSPEC_PROPID;
246 U(spec).propid = PIDSI_AUTHOR;
247 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
248 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
249 ok(var.vt == VT_LPSTR && !lstrcmpA(U(var).pszVal, val),
250 "Didn't get expected type or value for property (got type %d, value %s)\n",
251 var.vt, U(var).pszVal);
253 IPropertyStorage_Release(propertyStorage);
254 IPropertySetStorage_Release(propSetStorage);
255 IStorage_Release(storage);
257 DeleteFileW(filename);
260 static void testCodepage(void)
262 static const WCHAR szDot[] = { '.',0 };
263 static const WCHAR szPrefix[] = { 's','t','g',0 };
264 static const WCHAR wval[] = { 'h','i',0 };
266 IStorage *storage = NULL;
267 IPropertySetStorage *propSetStorage = NULL;
268 IPropertyStorage *propertyStorage = NULL;
271 WCHAR fileName[MAX_PATH];
273 if(!GetTempFileNameW(szDot, szPrefix, 0, fileName))
276 hr = StgCreateDocfile(fileName,
277 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
278 ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr);
280 if(!pStgCreatePropSetStg)
282 IStorage_Release(storage);
283 DeleteFileW(fileName);
286 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
287 ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
289 hr = IPropertySetStorage_Create(propSetStorage,
290 &FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
291 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
293 ok(SUCCEEDED(hr), "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
295 PropVariantInit(&var);
296 spec.ulKind = PRSPEC_PROPID;
297 U(spec).propid = PID_CODEPAGE;
298 /* check code page before it's been explicitly set */
299 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
300 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
301 ok(var.vt == VT_I2 && U(var).iVal == 1200,
302 "Didn't get expected type or value for property\n");
303 /* Set the code page to ascii */
306 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
307 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
308 /* check code page */
309 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
310 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
311 ok(var.vt == VT_I2 && U(var).iVal == 1252,
312 "Didn't get expected type or value for property\n");
313 /* Set code page to Unicode */
315 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
316 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
317 /* check code page */
318 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
319 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
320 ok(var.vt == VT_I2 && U(var).iVal == 1200,
321 "Didn't get expected type or value for property\n");
322 /* Set a string value */
323 spec.ulKind = PRSPEC_PROPID;
324 U(spec).propid = PID_FIRST_USABLE;
326 U(var).pszVal = "hi";
327 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
328 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
329 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
330 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
331 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "hi"),
332 "Didn't get expected type or value for property\n");
333 /* This seemingly non-sensical test is to show that the string is indeed
334 * interpreted according to the current system code page, not according to
335 * the property set's code page. (If the latter were true, the whole
336 * string would be maintained. As it is, only the first character is.)
338 U(var).pszVal = (LPSTR)wval;
339 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
340 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
341 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
342 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
343 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "h"),
344 "Didn't get expected type or value for property\n");
345 /* now that a property's been set, you can't change the code page */
346 spec.ulKind = PRSPEC_PROPID;
347 U(spec).propid = PID_CODEPAGE;
350 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
351 ok(hr == STG_E_INVALIDPARAMETER,
352 "Expected STG_E_INVALIDPARAMETER, got 0x%08lx\n", hr);
354 IPropertyStorage_Release(propertyStorage);
355 IPropertySetStorage_Release(propSetStorage);
356 IStorage_Release(storage);
358 DeleteFileW(fileName);
360 /* same tests, but with PROPSETFLAG_ANSI */
361 hr = StgCreateDocfile(fileName,
362 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
363 ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr);
365 hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
366 ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
368 hr = IPropertySetStorage_Create(propSetStorage,
369 &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
370 STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
372 ok(SUCCEEDED(hr), "IPropertySetStorage_Create failed: 0x%08lx\n", hr);
374 /* check code page before it's been explicitly set */
375 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
376 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
377 ok(var.vt == VT_I2 && U(var).iVal == 1252,
378 "Didn't get expected type or value for property\n");
379 /* Set code page to Unicode */
381 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
382 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
383 /* check code page */
384 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
385 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
386 ok(var.vt == VT_I2 && U(var).iVal == 1200,
387 "Didn't get expected type or value for property\n");
388 /* This test is commented out for documentation. It fails under Wine,
389 * and I expect it would under Windows as well, yet it succeeds. There's
390 * obviously something about string conversion I don't understand.
393 static const char strVal[] = { 0x81, 0xff, 0x04, 0 };
394 /* Set code page to 950 (Traditional Chinese) */
396 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
397 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
398 /* Try writing an invalid string: lead byte 0x81 is unused in Traditional
401 spec.ulKind = PRSPEC_PROPID;
402 U(spec).propid = PID_FIRST_USABLE;
404 U(var).pszVal = (LPSTR)strVal;
405 hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
406 ok(SUCCEEDED(hr), "WriteMultiple failed: 0x%08lx\n", hr);
407 /* Check returned string */
408 hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
409 ok(SUCCEEDED(hr), "ReadMultiple failed: 0x%08lx\n", hr);
410 ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, strVal),
411 "Didn't get expected type or value for property\n");
414 IPropertyStorage_Release(propertyStorage);
415 IPropertySetStorage_Release(propSetStorage);
416 IStorage_Release(storage);
418 DeleteFileW(fileName);
421 static void testFmtId(void)
423 WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
424 'I','n','f','o','r','m','a','t','i','o','n',0 };
425 WCHAR szDocSummaryInfo[] = { 5,'D','o','c','u','m','e','n','t',
426 'S','u','m','m','a','r','y','I','n','f','o','r','m','a','t','i','o','n',
428 WCHAR szIID_IPropSetStg[] = { 5,'0','j','a','a','a','a','a',
429 'a','A','a','a','a','a','a','d','a','A','a','a','a','a','a','a','a','G',
435 if (pFmtIdToPropStgName) {
436 hr = pFmtIdToPropStgName(NULL, name);
437 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
438 hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL);
439 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
440 hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name);
441 ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
442 ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) *
443 sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n");
444 hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name);
445 ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
446 ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
447 sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
448 hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name);
449 ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
450 ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
451 sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
452 hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name);
453 ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
454 ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) *
455 sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n");
458 if(pPropStgNameToFmtId) {
459 /* test args first */
460 hr = pPropStgNameToFmtId(NULL, NULL);
461 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
462 hr = pPropStgNameToFmtId(NULL, &fmtid);
463 ok(hr == STG_E_INVALIDNAME, "Expected STG_E_INVALIDNAME, got 0x%08lx\n",
465 hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL);
466 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
467 /* test the known format IDs */
468 hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid);
469 ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
470 ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)),
471 "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
472 hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
473 ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
474 ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
475 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
476 /* test another GUID */
477 hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
478 ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
479 ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
480 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
481 /* now check case matching */
482 CharUpperW(szDocSummaryInfo + 1);
483 hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
484 ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
485 ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
486 "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
487 CharUpperW(szIID_IPropSetStg + 1);
488 hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
489 ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
490 ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
491 "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
497 init_function_pointers();