Module: wine Branch: master Commit: d177709b10ce07ddd234b0e8e00764ae4b1d8488 URL: https://gitlab.winehq.org/wine/wine/-/commit/d177709b10ce07ddd234b0e8e00764a...
Author: Fabian Maurer dark.shadow4@web.de Date: Sun Oct 8 19:35:44 2023 +0200
propsys: Implement PropVariantToUInt32WithDefault.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55713
---
dlls/propsys/propsys.spec | 2 +- dlls/propsys/propvar.c | 14 ++++++++++++++ dlls/propsys/tests/propsys.c | 9 +++++++++ include/propvarutil.h | 1 + 4 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/dlls/propsys/propsys.spec b/dlls/propsys/propsys.spec index b2d48a87577..20615dd3aed 100644 --- a/dlls/propsys/propsys.spec +++ b/dlls/propsys/propsys.spec @@ -145,7 +145,7 @@ @ stdcall PropVariantToUInt32(ptr ptr) @ stub PropVariantToUInt32Vector @ stub PropVariantToUInt32VectorAlloc -@ stub PropVariantToUInt32WithDefault +@ stdcall PropVariantToUInt32WithDefault(ptr long) @ stdcall PropVariantToUInt64(ptr ptr) @ stub PropVariantToUInt64Vector @ stub PropVariantToUInt64VectorAlloc diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c index c6510f9f35d..8702d31561f 100644 --- a/dlls/propsys/propvar.c +++ b/dlls/propsys/propvar.c @@ -229,6 +229,20 @@ HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret) return hr; }
+ULONG WINAPI PropVariantToUInt32WithDefault(REFPROPVARIANT propvarIn, ULONG ulDefault) +{ + LONGLONG res; + HRESULT hr; + + TRACE("%p,%lu\n", propvarIn, ulDefault); + + hr = PROPVAR_ConvertNumber(propvarIn, 32, FALSE, &res); + if (SUCCEEDED(hr)) + return (ULONG)res; + + return ulDefault; +} + HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret) { LONGLONG res; diff --git a/dlls/propsys/tests/propsys.c b/dlls/propsys/tests/propsys.c index a2fbb619ef2..04816864080 100644 --- a/dlls/propsys/tests/propsys.c +++ b/dlls/propsys/tests/propsys.c @@ -966,6 +966,9 @@ static void test_intconversions(void) hr = PropVariantToUInt32(&propvar, &ulval); ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "hr=%lx\n", hr);
+ ulval = PropVariantToUInt32WithDefault(&propvar, 77); + ok(ulval == 77, "ulval=%lu\n", ulval); + hr = PropVariantToInt16(&propvar, &sval); ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "hr=%lx\n", hr);
@@ -991,6 +994,9 @@ static void test_intconversions(void) ok(hr == S_OK, "hr=%lx\n", hr); ok(ulval == 5, "got wrong value %ld\n", ulval);
+ ulval = PropVariantToUInt32WithDefault(&propvar, 77); + ok(ulval == 5, "got wrong value %lu\n", ulval); + hr = PropVariantToInt16(&propvar, &sval); ok(hr == S_OK, "hr=%lx\n", hr); ok(sval == 5, "got wrong value %d\n", sval); @@ -1016,6 +1022,9 @@ static void test_intconversions(void) hr = PropVariantToUInt32(&propvar, &ulval); ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "hr=%lx\n", hr);
+ ulval = PropVariantToUInt32WithDefault(&propvar, 77); + ok(ulval == 77, "ulval=%lu\n", ulval); + hr = PropVariantToInt16(&propvar, &sval); ok(hr == S_OK, "hr=%lx\n", hr); ok(sval == -5, "got wrong value %d\n", sval); diff --git a/include/propvarutil.h b/include/propvarutil.h index 6c1878c6aa5..026304e3f15 100644 --- a/include/propvarutil.h +++ b/include/propvarutil.h @@ -89,6 +89,7 @@ HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret); HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret); HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret); HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret); +ULONG WINAPI PropVariantToUInt32WithDefault(REFPROPVARIANT propvarIn, ULONG uLDefault); HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret); HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret); HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb);