ole32: Add support for reading BSTR properties.
This commit is contained in:
parent
58c2462c36
commit
0a5086ab64
|
@ -58,6 +58,7 @@
|
|||
#include "dictionary.h"
|
||||
#include "storage32.h"
|
||||
#include "enumx.h"
|
||||
#include "oleauto.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(storage);
|
||||
|
||||
|
@ -1125,6 +1126,40 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const BYTE *data,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case VT_BSTR:
|
||||
{
|
||||
DWORD count, wcount;
|
||||
|
||||
StorageUtl_ReadDWord(data, 0, &count);
|
||||
if (codepage == CP_UNICODE && count % 2)
|
||||
{
|
||||
WARN("Unicode string has odd number of bytes\n");
|
||||
hr = STG_E_INVALIDHEADER;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (codepage == CP_UNICODE)
|
||||
wcount = count / 2;
|
||||
else
|
||||
wcount = MultiByteToWideChar(codepage, 0, (LPCSTR)(data + sizeof(DWORD)), count, NULL, 0);
|
||||
|
||||
prop->u.bstrVal = SysAllocStringLen(NULL, wcount); /* FIXME: use allocator? */
|
||||
|
||||
if (prop->u.bstrVal)
|
||||
{
|
||||
if (codepage == CP_UNICODE)
|
||||
memcpy(prop->u.bstrVal, data + sizeof(DWORD), count);
|
||||
else
|
||||
MultiByteToWideChar(codepage, 0, (LPCSTR)(data + sizeof(DWORD)), count, prop->u.bstrVal, wcount);
|
||||
|
||||
prop->u.bstrVal[wcount - 1] = '\0';
|
||||
TRACE("Read string value %s\n", debugstr_w(prop->u.bstrVal));
|
||||
}
|
||||
else
|
||||
hr = STG_E_INSUFFICIENTMEMORY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VT_BLOB:
|
||||
{
|
||||
DWORD count;
|
||||
|
|
|
@ -395,18 +395,16 @@ static void test_propertytovariant(void)
|
|||
CP_WINUNICODE, &propvar, &allocator);
|
||||
|
||||
ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
|
||||
todo_wine ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
|
||||
if (propvar.vt == VT_BSTR)
|
||||
ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
|
||||
ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
|
||||
ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
|
||||
PropVariantClear(&propvar);
|
||||
|
||||
ret = pStgConvertPropertyToVariant((SERIALIZEDPROPERTYVALUE*)serialized_bstr_mb,
|
||||
CP_UTF8, &propvar, &allocator);
|
||||
|
||||
ok(ret == 0, "StgConvertPropertyToVariant returned %i\n", ret);
|
||||
todo_wine ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
|
||||
if (propvar.vt == VT_BSTR)
|
||||
ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
|
||||
ok(propvar.vt == VT_BSTR, "unexpected vt %x\n", propvar.vt);
|
||||
ok(!lstrcmpW(U(propvar).bstrVal, test_string), "unexpected string value\n");
|
||||
PropVariantClear(&propvar);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue