Commit d177709b authored by Fabian Maurer's avatar Fabian Maurer Committed by Alexandre Julliard

propsys: Implement PropVariantToUInt32WithDefault.

parent 9e767992
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
@ stdcall PropVariantToUInt32(ptr ptr) @ stdcall PropVariantToUInt32(ptr ptr)
@ stub PropVariantToUInt32Vector @ stub PropVariantToUInt32Vector
@ stub PropVariantToUInt32VectorAlloc @ stub PropVariantToUInt32VectorAlloc
@ stub PropVariantToUInt32WithDefault @ stdcall PropVariantToUInt32WithDefault(ptr long)
@ stdcall PropVariantToUInt64(ptr ptr) @ stdcall PropVariantToUInt64(ptr ptr)
@ stub PropVariantToUInt64Vector @ stub PropVariantToUInt64Vector
@ stub PropVariantToUInt64VectorAlloc @ stub PropVariantToUInt64VectorAlloc
......
...@@ -229,6 +229,20 @@ HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret) ...@@ -229,6 +229,20 @@ HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret)
return hr; 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) HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
{ {
LONGLONG res; LONGLONG res;
......
...@@ -966,6 +966,9 @@ static void test_intconversions(void) ...@@ -966,6 +966,9 @@ static void test_intconversions(void)
hr = PropVariantToUInt32(&propvar, &ulval); hr = PropVariantToUInt32(&propvar, &ulval);
ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "hr=%lx\n", hr); 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); hr = PropVariantToInt16(&propvar, &sval);
ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "hr=%lx\n", hr); ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "hr=%lx\n", hr);
...@@ -991,6 +994,9 @@ static void test_intconversions(void) ...@@ -991,6 +994,9 @@ static void test_intconversions(void)
ok(hr == S_OK, "hr=%lx\n", hr); ok(hr == S_OK, "hr=%lx\n", hr);
ok(ulval == 5, "got wrong value %ld\n", ulval); 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); hr = PropVariantToInt16(&propvar, &sval);
ok(hr == S_OK, "hr=%lx\n", hr); ok(hr == S_OK, "hr=%lx\n", hr);
ok(sval == 5, "got wrong value %d\n", sval); ok(sval == 5, "got wrong value %d\n", sval);
...@@ -1016,6 +1022,9 @@ static void test_intconversions(void) ...@@ -1016,6 +1022,9 @@ static void test_intconversions(void)
hr = PropVariantToUInt32(&propvar, &ulval); hr = PropVariantToUInt32(&propvar, &ulval);
ok(hr == HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW), "hr=%lx\n", hr); 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); hr = PropVariantToInt16(&propvar, &sval);
ok(hr == S_OK, "hr=%lx\n", hr); ok(hr == S_OK, "hr=%lx\n", hr);
ok(sval == -5, "got wrong value %d\n", sval); ok(sval == -5, "got wrong value %d\n", sval);
......
...@@ -89,6 +89,7 @@ HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret); ...@@ -89,6 +89,7 @@ HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret);
HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret); HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret); HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret);
HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret); HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret);
ULONG WINAPI PropVariantToUInt32WithDefault(REFPROPVARIANT propvarIn, ULONG uLDefault);
HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret); HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret);
HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret); HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret);
HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb); HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment