[PATCH 2/7] propsys: Support VT_LPWSTR in PropVariantChangeType
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Fri Jul 1 02:56:55 CDT 2016
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
dlls/propsys/propvar.c | 14 ++++++++++++++
dlls/propsys/tests/propsys.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c
index 80b4d04..192ff43 100644
--- a/dlls/propsys/propvar.c
+++ b/dlls/propsys/propvar.c
@@ -260,6 +260,9 @@ HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT p
FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc,
propvarSrc->vt, flags, vt);
+ if(vt == propvarSrc->vt)
+ return PropVariantCopy(ppropvarDest, propvarSrc);
+
switch (vt)
{
case VT_I2:
@@ -328,6 +331,17 @@ HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT p
}
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)
diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c
index d7d83d8..b658678 100644
--- a/dlls/propsys/tests/propsys.c
+++ b/dlls/propsys/tests/propsys.c
@@ -891,6 +891,42 @@ static void test_intconversions(void)
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)
{
test_PSStringFromPropertyKey();
@@ -902,4 +938,5 @@ START_TEST(propsys)
test_PropVariantToStringAlloc();
test_PropVariantCompare();
test_intconversions();
+ test_PropVariantChangeType_LPWSTR();
}
--
1.9.1
More information about the wine-patches
mailing list