Alistair Leslie-Hughes : propsys: Support VT_LPWSTR in PropVariantChangeType.

Alexandre Julliard julliard at winehq.org
Wed Jul 6 09:57:31 CDT 2016


Module: wine
Branch: master
Commit: 173515e7333e6c06405c2999f93825aa96c82452
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=173515e7333e6c06405c2999f93825aa96c82452

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Fri Jul  1 07:56:55 2016 +0000

propsys: Support VT_LPWSTR in PropVariantChangeType.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 7b1cec5..002555e 100644
--- a/dlls/propsys/propvar.c
+++ b/dlls/propsys/propvar.c
@@ -257,6 +257,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:
@@ -325,6 +328,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();
 }




More information about the wine-cvs mailing list