propsys: Support VT_LPWSTR in PropVariantChangeType.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2016-07-01 07:56:55 +00:00 committed by Alexandre Julliard
parent 1807e5346f
commit 173515e733
2 changed files with 51 additions and 0 deletions

View File

@ -257,6 +257,9 @@ HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT p
FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc, FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc,
propvarSrc->vt, flags, vt); propvarSrc->vt, flags, vt);
if(vt == propvarSrc->vt)
return PropVariantCopy(ppropvarDest, propvarSrc);
switch (vt) switch (vt)
{ {
case VT_I2: case VT_I2:
@ -325,6 +328,17 @@ HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT p
} }
return hr; return hr;
} }
case VT_LPWSTR:
{
WCHAR *res;
hr = PropVariantToStringAlloc(propvarSrc, &res);
if (SUCCEEDED(hr))
{
ppropvarDest->vt = VT_LPWSTR;
ppropvarDest->u.pwszVal = res;
}
return hr;
}
} }
switch (propvarSrc->vt) switch (propvarSrc->vt)

View File

@ -891,6 +891,42 @@ static void test_intconversions(void)
ok(llval == -7, "got wrong value %s\n", debugstr_longlong(llval)); ok(llval == -7, "got wrong value %s\n", debugstr_longlong(llval));
} }
static void test_PropVariantChangeType_LPWSTR(void)
{
PROPVARIANT dest, src;
HRESULT hr;
PropVariantInit(&dest);
src.vt = VT_NULL;
hr = PropVariantChangeType(&dest, &src, 0, VT_LPWSTR);
ok(hr == S_OK, "hr=%x\n", hr);
ok(dest.vt == VT_LPWSTR, "got %d\n", dest.vt);
ok(!lstrcmpW(dest.u.pwszVal, emptyW), "got %s\n", wine_dbgstr_w(dest.u.pwszVal));
PropVariantClear(&dest);
PropVariantClear(&src);
src.vt = VT_LPSTR;
src.u.pszVal = CoTaskMemAlloc(strlen(topic)+1);
strcpy(src.u.pszVal, topic);
hr = PropVariantChangeType(&dest, &src, 0, VT_LPWSTR);
ok(hr == S_OK, "hr=%x\n", hr);
ok(dest.vt == VT_LPWSTR, "got %d\n", dest.vt);
ok(!lstrcmpW(dest.u.pwszVal, topicW), "got %s\n", wine_dbgstr_w(dest.u.pwszVal));
PropVariantClear(&dest);
PropVariantClear(&src);
src.vt = VT_LPWSTR;
src.u.pwszVal = CoTaskMemAlloc( (lstrlenW(topicW)+1) * sizeof(WCHAR));
lstrcpyW(src.u.pwszVal, topicW);
hr = PropVariantChangeType(&dest, &src, 0, VT_LPWSTR);
ok(hr == S_OK, "hr=%x\n", hr);
ok(dest.vt == VT_LPWSTR, "got %d\n", dest.vt);
ok(!lstrcmpW(dest.u.pwszVal, topicW), "got %s\n", wine_dbgstr_w(dest.u.pwszVal));
PropVariantClear(&dest);
PropVariantClear(&src);
}
START_TEST(propsys) START_TEST(propsys)
{ {
test_PSStringFromPropertyKey(); test_PSStringFromPropertyKey();
@ -902,4 +938,5 @@ START_TEST(propsys)
test_PropVariantToStringAlloc(); test_PropVariantToStringAlloc();
test_PropVariantCompare(); test_PropVariantCompare();
test_intconversions(); test_intconversions();
test_PropVariantChangeType_LPWSTR();
} }