2005-04-11 16:30:24 +02:00
|
|
|
/* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-04-11 16:30:24 +02:00
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2006-07-12 07:53:57 +02:00
|
|
|
#ifndef PID_BEHAVIOR
|
|
|
|
#define PID_BEHAVIOR 0x80000003
|
|
|
|
#endif
|
|
|
|
|
2005-04-22 21:05:51 +02:00
|
|
|
static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
|
|
|
|
static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
|
|
|
|
static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
|
2016-04-11 00:22:24 +02:00
|
|
|
static HRESULT (WINAPI *pStgCreatePropStg)(IUnknown *, REFFMTID, const CLSID *, DWORD, DWORD, IPropertyStorage **);
|
|
|
|
static HRESULT (WINAPI *pStgOpenPropStg)(IUnknown *, REFFMTID, DWORD, DWORD, IPropertyStorage **);
|
2005-04-22 21:05:51 +02:00
|
|
|
|
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
|
|
|
HMODULE hmod = GetModuleHandleA("ole32.dll");
|
2007-03-28 10:00:28 +02:00
|
|
|
pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
|
|
|
|
pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
|
|
|
|
pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
|
2016-04-11 00:22:24 +02:00
|
|
|
pStgCreatePropStg = (void*)GetProcAddress(hmod, "StgCreatePropStg");
|
|
|
|
pStgOpenPropStg = (void*)GetProcAddress(hmod, "StgOpenPropStg");
|
2005-04-22 21:05:51 +02:00
|
|
|
}
|
2016-04-11 00:22:24 +02:00
|
|
|
|
2005-04-11 20:50:45 +02:00
|
|
|
/* FIXME: this creates an ANSI storage, try to find conditions under which
|
2005-04-11 16:30:24 +02:00
|
|
|
* Unicode translation fails
|
|
|
|
*/
|
2016-04-11 00:22:24 +02:00
|
|
|
static void testPropsHelper(IPropertySetStorage **propSetStorage)
|
2005-04-11 16:30:24 +02:00
|
|
|
{
|
|
|
|
static const WCHAR szDot[] = { '.',0 };
|
|
|
|
static const WCHAR szPrefix[] = { 's','t','g',0 };
|
2016-04-11 00:22:24 +02:00
|
|
|
static const WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
|
|
|
|
'I','n','f','o','r','m','a','t','i','o','n',0 };
|
2007-01-08 20:59:08 +01:00
|
|
|
static WCHAR propName[] = { 'p','r','o','p',0 };
|
|
|
|
static char val[] = "l33t auth0r";
|
2005-04-11 16:30:24 +02:00
|
|
|
WCHAR filename[MAX_PATH];
|
|
|
|
HRESULT hr;
|
|
|
|
IStorage *storage = NULL;
|
2016-04-11 00:22:24 +02:00
|
|
|
IStream *stream = NULL;
|
2005-04-11 16:30:24 +02:00
|
|
|
IPropertyStorage *propertyStorage = NULL;
|
|
|
|
PROPSPEC spec;
|
|
|
|
PROPVARIANT var;
|
2006-07-12 11:23:30 +02:00
|
|
|
CLIPDATA clipdata;
|
|
|
|
unsigned char clipcontent[] = "foobar";
|
2010-05-24 21:10:40 +02:00
|
|
|
GUID anyOldGuid = { 0x12345678,0xdead,0xbeef, {
|
|
|
|
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07 } };
|
2005-04-11 16:30:24 +02:00
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage)
|
|
|
|
trace("Testing property storage with a set...\n");
|
|
|
|
else
|
|
|
|
trace("Testing property storage without a set...\n");
|
|
|
|
|
2005-04-11 16:30:24 +02:00
|
|
|
if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
|
|
|
|
return;
|
|
|
|
|
|
|
|
DeleteFileW(filename);
|
|
|
|
|
|
|
|
hr = StgCreateDocfile(filename,
|
|
|
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage)
|
2005-10-29 12:29:18 +02:00
|
|
|
{
|
2016-04-11 00:22:24 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IStorage_CreateStream(storage, szSummaryInfo,
|
|
|
|
STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
|
|
|
|
ok(hr == S_OK, "IStorage_CreateStream failed: 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if(!pStgCreatePropStg)
|
|
|
|
{
|
|
|
|
IStorage_Release(storage);
|
|
|
|
IUnknown_Release(stream);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = pStgCreatePropStg((IUnknown *)stream, &FMTID_SummaryInformation,
|
|
|
|
NULL, PROPSETFLAG_ANSI, 0, &propertyStorage);
|
|
|
|
ok(hr == S_OK, "StgCreatePropStg failed: 0x%08x\n", hr);
|
2005-10-29 12:29:18 +02:00
|
|
|
}
|
2005-04-11 16:30:24 +02:00
|
|
|
|
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple with 0 args failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, NULL, NULL, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
|
|
|
/* 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,
|
2006-10-14 04:54:46 +02:00
|
|
|
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
|
|
|
/* test setting one by name with an invalid propidNameFirst */
|
|
|
|
spec.ulKind = PRSPEC_LPWSTR;
|
2009-01-20 11:21:23 +01:00
|
|
|
U(spec).lpwstr = propName;
|
2005-04-11 16:30:24 +02:00
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
|
|
|
|
PID_DICTIONARY);
|
|
|
|
ok(hr == STG_E_INVALIDPARAMETER,
|
2006-10-14 04:54:46 +02:00
|
|
|
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
|
|
|
/* 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,
|
2006-10-14 04:54:46 +02:00
|
|
|
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
|
|
|
/* 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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
2005-04-11 20:50:45 +02:00
|
|
|
/* set one by name */
|
2005-04-11 16:30:24 +02:00
|
|
|
spec.ulKind = PRSPEC_LPWSTR;
|
2009-01-20 11:21:23 +01:00
|
|
|
U(spec).lpwstr = propName;
|
2005-04-11 16:30:24 +02:00
|
|
|
U(var).lVal = 2;
|
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
|
|
|
|
PID_FIRST_USABLE);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
2005-04-11 20:50:45 +02:00
|
|
|
/* set a string value */
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PIDSI_AUTHOR;
|
|
|
|
var.vt = VT_LPSTR;
|
2007-01-08 20:59:08 +01:00
|
|
|
U(var).pszVal = val;
|
2005-04-11 20:50:45 +02:00
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
|
2006-07-12 11:23:30 +02:00
|
|
|
/* 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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2006-07-12 11:23:30 +02:00
|
|
|
|
|
|
|
|
2005-04-11 16:30:24 +02:00
|
|
|
/* check reading */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 0, NULL, NULL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_FALSE, "ReadMultiple with 0 args failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, NULL, NULL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
/* read by propid */
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PID_FIRST_USABLE;
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
ok(var.vt == VT_I4 && U(var).lVal == 1,
|
2009-03-12 23:04:35 +01:00
|
|
|
"Didn't get expected type or value for property (got type %d, value %d)\n",
|
2005-04-11 16:30:24 +02:00
|
|
|
var.vt, U(var).lVal);
|
|
|
|
/* read by name */
|
|
|
|
spec.ulKind = PRSPEC_LPWSTR;
|
2009-01-20 11:21:23 +01:00
|
|
|
U(spec).lpwstr = propName;
|
2005-04-11 16:30:24 +02:00
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
ok(var.vt == VT_I4 && U(var).lVal == 2,
|
2009-03-12 23:04:35 +01:00
|
|
|
"Didn't get expected type or value for property (got type %d, value %d)\n",
|
2005-04-11 16:30:24 +02:00
|
|
|
var.vt, U(var).lVal);
|
2005-04-11 20:50:45 +02:00
|
|
|
/* read string value */
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PIDSI_AUTHOR;
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
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);
|
2009-12-15 22:04:42 +01:00
|
|
|
PropVariantClear(&var);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
2006-07-12 11:23:30 +02:00
|
|
|
/* read clipboard format */
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PIDSI_THUMBNAIL;
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2011-01-11 00:00:14 +01:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2006-07-12 11:23:30 +02:00
|
|
|
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");
|
|
|
|
|
2005-04-11 16:30:24 +02:00
|
|
|
/* check deleting */
|
|
|
|
hr = IPropertyStorage_DeleteMultiple(propertyStorage, 0, NULL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "DeleteMultiple with 0 args failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, NULL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
/* 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,
|
2006-10-14 04:54:46 +02:00
|
|
|
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
/* now delete the first value.. */
|
|
|
|
U(spec).propid = PID_FIRST_USABLE;
|
|
|
|
hr = IPropertyStorage_DeleteMultiple(propertyStorage, 1, &spec);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "DeleteMultiple failed: 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
/* and check that it's no longer readable */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08x\n", hr);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
2005-04-11 20:50:45 +02:00
|
|
|
hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
|
|
|
|
/* check reverting */
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PID_FIRST_USABLE;
|
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
hr = IPropertyStorage_Revert(propertyStorage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "Revert failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
/* now check that it's still not there */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_FALSE, "Expected S_FALSE, got 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
/* 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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
/* commit it */
|
|
|
|
hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
/* set it to a string value */
|
|
|
|
var.vt = VT_LPSTR;
|
2009-01-20 11:21:23 +01:00
|
|
|
U(var).pszVal = val;
|
2005-04-11 20:50:45 +02:00
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
/* revert it */
|
|
|
|
hr = IPropertyStorage_Revert(propertyStorage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "Revert failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* 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?
|
|
|
|
*/
|
2005-04-11 20:50:45 +02:00
|
|
|
|
|
|
|
IPropertyStorage_Release(propertyStorage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
2005-04-11 20:50:45 +02:00
|
|
|
IStorage_Release(storage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(stream) IUnknown_Release(stream);
|
2005-04-11 20:50:45 +02:00
|
|
|
|
|
|
|
/* now open it again */
|
|
|
|
hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
|
|
|
|
NULL, 0, &storage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage)
|
|
|
|
{
|
|
|
|
hr = pStgCreatePropSetStg(storage, 0, propSetStorage);
|
|
|
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
hr = IPropertySetStorage_Open(*propSetStorage, &FMTID_SummaryInformation,
|
|
|
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
|
|
|
|
ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IStorage_OpenStream(storage, szSummaryInfo,
|
|
|
|
0, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
|
|
|
|
ok(hr == S_OK, "IStorage_OpenStream failed: 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if(!pStgOpenPropStg)
|
|
|
|
{
|
|
|
|
IStorage_Release(storage);
|
|
|
|
IUnknown_Release(stream);
|
|
|
|
DeleteFileW(filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = pStgOpenPropStg((IUnknown *)stream, &FMTID_SummaryInformation,
|
|
|
|
PROPSETFLAG_DEFAULT, 0, &propertyStorage);
|
|
|
|
ok(hr == S_OK, "StgOpenPropStg failed: 0x%08x\n", hr);
|
|
|
|
}
|
2005-04-11 20:50:45 +02:00
|
|
|
|
|
|
|
/* check properties again */
|
|
|
|
spec.ulKind = PRSPEC_LPWSTR;
|
2009-01-20 11:21:23 +01:00
|
|
|
U(spec).lpwstr = propName;
|
2005-04-11 20:50:45 +02:00
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
ok(var.vt == VT_I4 && U(var).lVal == 2,
|
2009-03-12 23:04:35 +01:00
|
|
|
"Didn't get expected type or value for property (got type %d, value %d)\n",
|
2005-04-11 20:50:45 +02:00
|
|
|
var.vt, U(var).lVal);
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PIDSI_AUTHOR;
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-11 20:50:45 +02:00
|
|
|
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);
|
2009-12-15 22:04:42 +01:00
|
|
|
PropVariantClear(&var);
|
2005-04-11 20:50:45 +02:00
|
|
|
|
2005-04-11 16:30:24 +02:00
|
|
|
IPropertyStorage_Release(propertyStorage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
2005-04-11 16:30:24 +02:00
|
|
|
IStorage_Release(storage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(stream) IUnknown_Release(stream);
|
2005-04-11 16:30:24 +02:00
|
|
|
|
|
|
|
DeleteFileW(filename);
|
2010-05-24 21:10:40 +02:00
|
|
|
|
|
|
|
/* Test creating a property set storage with a random GUID */
|
|
|
|
hr = StgCreateDocfile(filename,
|
|
|
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
|
|
|
|
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage)
|
2010-05-24 21:10:40 +02:00
|
|
|
{
|
2016-04-11 00:22:24 +02:00
|
|
|
hr = pStgCreatePropSetStg(storage, 0, propSetStorage);
|
|
|
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Create(*propSetStorage,
|
|
|
|
&anyOldGuid, NULL, PROPSETFLAG_ANSI,
|
|
|
|
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
|
|
|
|
&propertyStorage);
|
|
|
|
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
|
2010-05-24 21:10:40 +02:00
|
|
|
}
|
2016-04-11 00:22:24 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IStorage_CreateStream(storage, szSummaryInfo,
|
|
|
|
STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
|
|
|
|
ok(hr == S_OK, "IStorage_CreateStream failed: 0x%08x\n", hr);
|
2010-05-24 21:10:40 +02:00
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
hr = pStgCreatePropStg((IUnknown *)stream, &anyOldGuid, NULL,
|
|
|
|
PROPSETFLAG_DEFAULT, 0, &propertyStorage);
|
|
|
|
ok(hr == S_OK, "StgCreatePropStg failed: 0x%08x\n", hr);
|
|
|
|
}
|
2010-05-24 21:10:40 +02:00
|
|
|
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PID_FIRST_USABLE;
|
2010-11-20 20:47:31 +01:00
|
|
|
var.vt = VT_I4;
|
2010-05-24 21:10:40 +02:00
|
|
|
U(var).lVal = 1;
|
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
|
|
|
|
2010-11-20 20:47:31 +01:00
|
|
|
hr = IPropertyStorage_Commit(propertyStorage, STGC_DEFAULT);
|
|
|
|
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
|
|
|
|
|
2010-05-24 21:10:40 +02:00
|
|
|
IPropertyStorage_Release(propertyStorage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
2010-05-24 21:10:40 +02:00
|
|
|
IStorage_Release(storage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(stream) IUnknown_Release(stream);
|
2010-05-24 21:10:40 +02:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage)
|
|
|
|
{
|
|
|
|
hr = pStgCreatePropSetStg(storage, 0, propSetStorage);
|
|
|
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Open(*propSetStorage, &anyOldGuid,
|
|
|
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
|
|
|
|
ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = IStorage_OpenStream(storage, szSummaryInfo,
|
|
|
|
0, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
|
|
|
|
ok(hr == S_OK, "IStorage_OpenStream failed: 0x%08x\n", hr);
|
2010-05-24 21:10:40 +02:00
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
hr = pStgOpenPropStg((IUnknown *)stream, &anyOldGuid,
|
|
|
|
PROPSETFLAG_DEFAULT, 0, &propertyStorage);
|
|
|
|
ok(hr == S_OK, "StgOpenPropStg failed: 0x%08x\n", hr);
|
|
|
|
}
|
2010-05-24 21:10:40 +02:00
|
|
|
|
|
|
|
spec.ulKind = PRSPEC_PROPID;
|
|
|
|
U(spec).propid = PID_FIRST_USABLE;
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2010-11-20 20:47:31 +01:00
|
|
|
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);
|
2010-05-24 21:10:40 +02:00
|
|
|
|
|
|
|
IPropertyStorage_Release(propertyStorage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
2010-05-24 21:10:40 +02:00
|
|
|
IStorage_Release(storage);
|
2016-04-11 00:22:24 +02:00
|
|
|
if(stream) IUnknown_Release(stream);
|
2010-05-24 21:10:40 +02:00
|
|
|
|
|
|
|
DeleteFileW(filename);
|
2005-04-11 16:30:24 +02:00
|
|
|
}
|
|
|
|
|
2016-04-11 00:22:24 +02:00
|
|
|
static void testProps(void)
|
|
|
|
{
|
|
|
|
IPropertySetStorage *propSetStorage = NULL;
|
|
|
|
|
|
|
|
testPropsHelper(&propSetStorage);
|
|
|
|
testPropsHelper(NULL);
|
|
|
|
}
|
|
|
|
|
2005-06-15 12:20:30 +02:00
|
|
|
static void testCodepage(void)
|
2005-04-23 21:04:49 +02:00
|
|
|
{
|
|
|
|
static const WCHAR szDot[] = { '.',0 };
|
|
|
|
static const WCHAR szPrefix[] = { 's','t','g',0 };
|
2006-06-22 20:23:13 +02:00
|
|
|
static CHAR aval[] = "hi";
|
2007-01-08 20:59:08 +01:00
|
|
|
static WCHAR wval[] = { 'h','i',0 };
|
2005-04-23 21:04:49 +02:00
|
|
|
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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
|
2005-10-29 12:29:18 +02:00
|
|
|
if(!pStgCreatePropSetStg)
|
|
|
|
{
|
|
|
|
IStorage_Release(storage);
|
|
|
|
DeleteFileW(fileName);
|
|
|
|
return;
|
|
|
|
}
|
2005-05-07 14:09:58 +02:00
|
|
|
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
|
|
|
|
hr = IPropertySetStorage_Create(propSetStorage,
|
|
|
|
&FMTID_SummaryInformation, NULL, PROPSETFLAG_DEFAULT,
|
|
|
|
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
|
|
|
|
&propertyStorage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
|
|
|
|
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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* check code page */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* check code page */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
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;
|
2006-06-22 20:23:13 +02:00
|
|
|
U(var).pszVal = aval;
|
2005-04-23 21:04:49 +02:00
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "hi"),
|
|
|
|
"Didn't get expected type or value for property\n");
|
2009-12-15 22:04:42 +01:00
|
|
|
PropVariantClear(&var);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* 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.)
|
|
|
|
*/
|
2009-12-15 22:04:42 +01:00
|
|
|
var.vt = VT_LPSTR;
|
2005-04-23 21:04:49 +02:00
|
|
|
U(var).pszVal = (LPSTR)wval;
|
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, "h"),
|
|
|
|
"Didn't get expected type or value for property\n");
|
2009-12-15 22:04:42 +01:00
|
|
|
PropVariantClear(&var);
|
|
|
|
|
2005-04-23 21:04:49 +02:00
|
|
|
/* 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,
|
2006-10-14 04:54:46 +02:00
|
|
|
"Expected STG_E_INVALIDPARAMETER, got 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
|
|
|
|
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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
|
2005-05-07 14:09:58 +02:00
|
|
|
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
|
|
|
|
hr = IPropertySetStorage_Create(propSetStorage,
|
|
|
|
&FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
|
|
|
|
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
|
|
|
|
&propertyStorage);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
|
|
|
|
/* check code page before it's been explicitly set */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2008-11-13 21:45:41 +01:00
|
|
|
ok(var.vt == VT_I2, "Didn't get expected type for property (%u)\n", var.vt);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* Set code page to Unicode */
|
|
|
|
U(var).iVal = 1200;
|
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* check code page */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
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.
|
|
|
|
*/
|
2005-06-15 12:20:30 +02:00
|
|
|
if(0) {
|
2007-01-08 20:59:08 +01:00
|
|
|
static unsigned char strVal[] = { 0x81, 0xff, 0x04, 0 };
|
2005-04-23 21:04:49 +02:00
|
|
|
/* Set code page to 950 (Traditional Chinese) */
|
|
|
|
U(var).iVal = 950;
|
|
|
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* 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);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
2005-04-23 21:04:49 +02:00
|
|
|
/* Check returned string */
|
|
|
|
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
2006-07-12 07:53:57 +02:00
|
|
|
ok(var.vt == VT_LPSTR && !strcmp(U(var).pszVal, (LPCSTR)strVal),
|
2005-04-23 21:04:49 +02:00
|
|
|
"Didn't get expected type or value for property\n");
|
2005-06-15 12:20:30 +02:00
|
|
|
}
|
2005-04-23 21:04:49 +02:00
|
|
|
|
|
|
|
IPropertyStorage_Release(propertyStorage);
|
|
|
|
IPropertySetStorage_Release(propSetStorage);
|
|
|
|
IStorage_Release(storage);
|
|
|
|
|
|
|
|
DeleteFileW(fileName);
|
|
|
|
}
|
|
|
|
|
2005-04-15 16:09:18 +02:00
|
|
|
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;
|
|
|
|
|
2005-04-22 21:05:51 +02:00
|
|
|
if (pFmtIdToPropStgName) {
|
|
|
|
hr = pFmtIdToPropStgName(NULL, name);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) *
|
|
|
|
sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n");
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
|
|
|
|
sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
|
|
|
|
sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) *
|
|
|
|
sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n");
|
2005-04-22 21:05:51 +02:00
|
|
|
}
|
2005-04-15 16:09:18 +02:00
|
|
|
|
2005-04-22 21:05:51 +02:00
|
|
|
if(pPropStgNameToFmtId) {
|
2005-04-15 16:09:18 +02:00
|
|
|
/* test args first */
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(NULL, NULL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(NULL, &fmtid);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == STG_E_INVALIDNAME, "Expected STG_E_INVALIDNAME, got 0x%08x\n",
|
2005-04-23 21:04:49 +02:00
|
|
|
hr);
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
/* test the known format IDs */
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)),
|
|
|
|
"Got unexpected FMTID, expected FMTID_SummaryInformation\n");
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
|
|
|
|
"Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
|
|
|
|
/* test another GUID */
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
|
|
|
|
"Got unexpected FMTID, expected IID_IPropertySetStorage\n");
|
|
|
|
/* now check case matching */
|
|
|
|
CharUpperW(szDocSummaryInfo + 1);
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
|
|
|
|
"Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
|
|
|
|
CharUpperW(szIID_IPropSetStg + 1);
|
2005-04-22 21:05:51 +02:00
|
|
|
hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
|
2006-10-14 04:54:46 +02:00
|
|
|
ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr);
|
2005-04-15 16:09:18 +02:00
|
|
|
ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
|
|
|
|
"Got unexpected FMTID, expected IID_IPropertySetStorage\n");
|
2005-06-15 12:20:30 +02:00
|
|
|
}
|
2005-04-22 21:05:51 +02:00
|
|
|
}
|
2005-04-15 16:09:18 +02:00
|
|
|
|
2019-11-08 14:33:52 +01:00
|
|
|
static void test_propertyset_storage_enum(void)
|
|
|
|
{
|
|
|
|
IPropertyStorage *prop_storage, *prop_storage2;
|
|
|
|
IPropertySetStorage *ps_storage;
|
|
|
|
IEnumSTATPROPSETSTG *ps_enum;
|
|
|
|
WCHAR filename[MAX_PATH];
|
|
|
|
STATPROPSETSTG psstg;
|
|
|
|
DWORD ret, fetched;
|
|
|
|
IStorage *storage;
|
|
|
|
FILETIME ftime;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
ret = GetTempFileNameW(L".", L"stg", 0, filename);
|
|
|
|
ok(ret, "Failed to get temporary file name.\n");
|
|
|
|
|
|
|
|
hr = StgCreateDocfile(filename, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
|
|
|
|
ok(hr == S_OK, "Failed to crate storage, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = StgCreatePropSetStg(storage, 0, &ps_storage);
|
|
|
|
ok(hr == S_OK, "Failed to create property set storage, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Create(ps_storage, &FMTID_SummaryInformation, &IID_IUnknown, PROPSETFLAG_ANSI,
|
|
|
|
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &prop_storage);
|
|
|
|
ok(hr == S_OK, "Failed to create property storage, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertyStorage_Stat(prop_storage, &psstg);
|
|
|
|
ok(hr == S_OK, "Failed to get prop storage stats, hr %#x.\n", hr);
|
|
|
|
todo_wine
|
|
|
|
ok(IsEqualCLSID(&psstg.clsid, &IID_IUnknown), "Unexpected storage clsid %s.\n", wine_dbgstr_guid(&psstg.clsid));
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Enum(ps_storage, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Enum(ps_storage, &ps_enum);
|
|
|
|
ok(hr == S_OK, "Failed to get enum object, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
memset(&psstg, 0, sizeof(psstg));
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
ok(hr == S_OK, "Failed to get enum item, hr %#x.\n", hr);
|
|
|
|
ok(fetched == 1, "Unexpected fetched count.\n");
|
|
|
|
ok(IsEqualCLSID(&psstg.fmtid, &FMTID_SummaryInformation), "Unexpected fmtid %s.\n",
|
|
|
|
wine_dbgstr_guid(&psstg.fmtid));
|
|
|
|
ok(psstg.mtime.dwHighDateTime == 0 && psstg.mtime.dwLowDateTime == 0, "Unexpected mtime %#x / %#x.\n",
|
|
|
|
psstg.mtime.dwHighDateTime, psstg.mtime.dwLowDateTime);
|
|
|
|
|
|
|
|
memset(&ftime, 0, sizeof(ftime));
|
|
|
|
ftime.dwLowDateTime = 1;
|
|
|
|
hr = IPropertyStorage_SetTimes(prop_storage, NULL, NULL, &ftime);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "Failed to set storage times, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IEnumSTATPROPSETSTG_Reset(ps_enum);
|
|
|
|
ok(hr == S_OK, "Failed to reset enumerator, hr %#x.\n", hr);
|
|
|
|
memset(&psstg, 0, sizeof(psstg));
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
ok(hr == S_OK, "Failed to get enum item, hr %#x.\n", hr);
|
|
|
|
ok(fetched == 1, "Unexpected fetched count.\n");
|
|
|
|
ok(IsEqualCLSID(&psstg.fmtid, &FMTID_SummaryInformation), "Unexpected fmtid %s.\n",
|
|
|
|
wine_dbgstr_guid(&psstg.fmtid));
|
|
|
|
ok(psstg.mtime.dwHighDateTime == 0 && psstg.mtime.dwLowDateTime == 0, "Unexpected mtime %#x / %#x.\n",
|
|
|
|
psstg.mtime.dwHighDateTime, psstg.mtime.dwLowDateTime);
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
ok(hr == S_FALSE, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IPropertySetStorage_Create(ps_storage, &FMTID_SummaryInformation, &IID_IUnknown, PROPSETFLAG_ANSI,
|
|
|
|
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &prop_storage2);
|
|
|
|
ok(hr == S_OK, "Failed to create property storage, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IEnumSTATPROPSETSTG_Reset(ps_enum);
|
|
|
|
ok(hr == S_OK, "Failed to reset enumerator, hr %#x.\n", hr);
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
ok(hr == S_OK, "Failed to get enum item, hr %#x.\n", hr);
|
|
|
|
ok(fetched == 1, "Unexpected fetched count.\n");
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
ok(hr == S_FALSE, "Failed to get enum item, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
/* Skipping. */
|
|
|
|
hr = IEnumSTATPROPSETSTG_Reset(ps_enum);
|
|
|
|
ok(hr == S_OK, "Failed to reset enumerator, hr %#x.\n", hr);
|
|
|
|
hr = IEnumSTATPROPSETSTG_Skip(ps_enum, 2);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_FALSE, "Failed to skip, hr %#x.\n", hr);
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_FALSE, "Failed to get enum item, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IEnumSTATPROPSETSTG_Reset(ps_enum);
|
|
|
|
ok(hr == S_OK, "Failed to reset enumerator, hr %#x.\n", hr);
|
|
|
|
hr = IEnumSTATPROPSETSTG_Skip(ps_enum, 1);
|
|
|
|
ok(hr == S_OK, "Failed to skip, hr %#x.\n", hr);
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_FALSE, "Failed to get enum item, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IEnumSTATPROPSETSTG_Reset(ps_enum);
|
|
|
|
ok(hr == S_OK, "Failed to reset enumerator, hr %#x.\n", hr);
|
|
|
|
todo_wine {
|
|
|
|
hr = IEnumSTATPROPSETSTG_Skip(ps_enum, 0);
|
|
|
|
ok(hr == S_FALSE, "Failed to skip, hr %#x.\n", hr);
|
|
|
|
hr = IEnumSTATPROPSETSTG_Next(ps_enum, 1, &psstg, &fetched);
|
|
|
|
ok(hr == S_FALSE, "Failed to get enum item, hr %#x.\n", hr);
|
|
|
|
}
|
|
|
|
IEnumSTATPROPSETSTG_Release(ps_enum);
|
|
|
|
|
|
|
|
IPropertyStorage_Release(prop_storage2);
|
|
|
|
IPropertyStorage_Release(prop_storage);
|
|
|
|
|
|
|
|
IPropertySetStorage_Release(ps_storage);
|
|
|
|
IStorage_Release(storage);
|
|
|
|
|
|
|
|
ret = DeleteFileW(filename);
|
|
|
|
ok(ret, "Failed to delete storage file.\n");
|
|
|
|
}
|
|
|
|
|
2005-04-11 16:30:24 +02:00
|
|
|
START_TEST(stg_prop)
|
|
|
|
{
|
2005-04-22 21:05:51 +02:00
|
|
|
init_function_pointers();
|
2005-04-11 16:30:24 +02:00
|
|
|
testProps();
|
2005-04-23 21:04:49 +02:00
|
|
|
testCodepage();
|
2005-04-15 16:09:18 +02:00
|
|
|
testFmtId();
|
2019-11-08 14:33:52 +01:00
|
|
|
test_propertyset_storage_enum();
|
2005-04-11 16:30:24 +02:00
|
|
|
}
|