From 909075ed5776aafae527c714daee1cfbd3fbd4f9 Mon Sep 17 00:00:00 2001 From: Ziqing Hui Date: Mon, 7 Oct 2024 11:17:48 +0800 Subject: [PATCH] propsys: Support converting to BSTR for PropVariantToVariant. --- dlls/propsys/propvar.c | 11 ++++++++++- dlls/propsys/tests/propsys.c | 15 --------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c index bbdca5f3fb3..d681b910e90 100644 --- a/dlls/propsys/propvar.c +++ b/dlls/propsys/propvar.c @@ -1069,6 +1069,8 @@ INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2 HRESULT WINAPI PropVariantToVariant(const PROPVARIANT *propvar, VARIANT *var) { + HRESULT hr = S_OK; + TRACE("propvar %p, var %p, propvar->vt %#x.\n", propvar, var, propvar ? propvar->vt : 0); if (!var || !propvar) @@ -1115,12 +1117,19 @@ HRESULT WINAPI PropVariantToVariant(const PROPVARIANT *propvar, VARIANT *var) case VT_R8: V_R8(var) = propvar->dblVal; break; + case VT_LPSTR: + case VT_LPWSTR: + case VT_BSTR: + case VT_CLSID: + var->vt = VT_BSTR; + hr = PropVariantToBSTR(propvar, &V_BSTR(var)); + break; default: FIXME("Unsupported type %d.\n", propvar->vt); return E_INVALIDARG; } - return S_OK; + return hr; } HRESULT WINAPI VariantToPropVariant(const VARIANT *var, PROPVARIANT *propvar) diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index a7396bd8983..3cdd1eb6e12 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -2592,14 +2592,10 @@ static void test_PropVariantToVariant(void) propvar.vt = VT_BSTR; propvar.bstrVal = SysAllocString(L"test"); hr = PropVariantToVariant(&propvar, &var); - todo_wine ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr); - if (hr == S_OK) - { ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var)); ok(V_BSTR(&var) != propvar.bstrVal, "Got same string pointer.\n"); ok(!wcscmp(V_BSTR(&var), propvar.bstrVal), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var))); - } PropVariantClear(&propvar); VariantClear(&var); @@ -2608,36 +2604,25 @@ static void test_PropVariantToVariant(void) hr = PropVariantToVariant(&propvar, &var); todo_wine ok(hr == 39, "PropVariantToVariant returned %#lx.\n", hr); - if (hr == 39) - { ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var)); ok(!wcscmp(V_BSTR(&var), dummy_guid_str), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var))); - } VariantClear(&var); propvar.vt = VT_LPSTR; propvar.pszVal = (char *)topic; hr = PropVariantToVariant(&propvar, &var); - todo_wine ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr); - if (hr == S_OK) - { ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var)); ok(!wcscmp(V_BSTR(&var), topicW), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var))); - } VariantClear(&var); propvar.vt = VT_LPWSTR; propvar.pwszVal = (WCHAR *)topicW; hr = PropVariantToVariant(&propvar, &var); - todo_wine ok(hr == S_OK, "PropVariantToVariant returned %#lx.\n", hr); - if (hr == S_OK) - { ok(V_VT(&var) == VT_BSTR, "Unexpected V_VT(&var) %d.\n", V_VT(&var)); ok(V_BSTR(&var) != topicW, "Got same string pointer.\n"); ok(!wcscmp(V_BSTR(&var), topicW), "Unexpected V_BSTR(&var) %s.\n", debugstr_w(V_BSTR(&var))); - } VariantClear(&var); }