From: Ziqing Hui zhui@codeweavers.com
--- dlls/propsys/propvar.c | 14 ++++++++++++-- dlls/propsys/tests/propsys.c | 6 +----- 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c index 4a60f2c2c7e..8892bc42f8d 100644 --- a/dlls/propsys/propvar.c +++ b/dlls/propsys/propvar.c @@ -334,9 +334,19 @@ HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret)
HRESULT WINAPI PropVariantToBSTR(REFPROPVARIANT propvar, BSTR *bstr) { - FIXME("propvar %p, bstr %p.\n", propvar, bstr); + WCHAR *str; + HRESULT hr; + + TRACE("propvar %p, propvar->vt %#x, bstr %p.\n", + propvar, propvar ? propvar->vt : 0, bstr); + + if (FAILED(hr = PropVariantToStringAlloc(propvar, &str))) + return hr; + + *bstr = SysAllocString(str); + CoTaskMemFree(str);
- return E_NOTIMPL; + return S_OK; }
HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb) diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index 67f522b44a0..d292695dab1 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -1678,10 +1678,10 @@ static void test_PropVariantToBSTR(void) check_PropVariantToBSTR(VT_BOOL, boolVal, TRUE, L"1"); check_PropVariantToBSTR(VT_R4, fltVal, 0.123f, L"0.123000003397464752"); check_PropVariantToBSTR(VT_R8, dblVal, 0.456f, L"0.456000000238418579"); + } check_PropVariantToBSTR(VT_CLSID, puuid, (CLSID *)&dummy_guid, dummy_guid_str); check_PropVariantToBSTR(VT_LPSTR, pszVal, (char *)topic, topicW); check_PropVariantToBSTR(VT_LPWSTR, pwszVal, (WCHAR *)topicW, topicW); - }
PropVariantInit(&propvar); propvar.vt = VT_FILETIME; @@ -1725,15 +1725,11 @@ static void test_PropVariantToBSTR(void) propvar.vt = VT_BSTR; propvar.bstrVal = SysAllocStringLen(test_bstr, ARRAY_SIZE(test_bstr)); hr = PropVariantToBSTR(&propvar, &bstr); - todo_wine ok(hr == S_OK, "PropVariantToBSTR returned %#lx.\n", hr); - if (hr == S_OK) - { length = SysStringLen(bstr); ok(length == wcslen(test_bstr), "Unexpected length %u.\n", length); ok(!wcscmp(bstr, test_bstr), "Unexpected bstr %s.", debugstr_wn(bstr, ARRAY_SIZE(test_bstr))); SysFreeString(bstr); - } PropVariantClear(&propvar); }