2008-02-27 09:38:14 +01:00
|
|
|
/*
|
|
|
|
* PropVariant implementation
|
|
|
|
*
|
|
|
|
* Copyright 2008 James Hawkins for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2017-06-22 05:38:46 +02:00
|
|
|
|
2008-02-27 09:38:14 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2017-06-22 05:38:46 +02:00
|
|
|
#include <stdlib.h>
|
2008-02-27 09:38:14 +01:00
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlobj.h"
|
|
|
|
#include "propvarutil.h"
|
2019-02-15 17:15:12 +01:00
|
|
|
#include "strsafe.h"
|
2008-02-27 09:38:14 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(propsys);
|
|
|
|
|
2017-06-20 06:36:56 +02:00
|
|
|
static HRESULT PROPVAR_ConvertFILETIME(const FILETIME *ft, PROPVARIANT *ppropvarDest, VARTYPE vt)
|
2008-02-27 09:38:14 +01:00
|
|
|
{
|
|
|
|
SYSTEMTIME time;
|
|
|
|
|
2017-06-20 06:36:56 +02:00
|
|
|
FileTimeToSystemTime(ft, &time);
|
2008-02-27 09:38:14 +01:00
|
|
|
|
|
|
|
switch (vt)
|
|
|
|
{
|
|
|
|
case VT_LPSTR:
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->pszVal = HeapAlloc(GetProcessHeap(), 0, 64);
|
|
|
|
if (!ppropvarDest->pszVal)
|
2008-02-27 09:38:14 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
sprintf( ppropvarDest->pszVal, "%04d/%02d/%02d:%02d:%02d:%02d.%03d",
|
2017-02-11 23:13:00 +01:00
|
|
|
time.wYear, time.wMonth, time.wDay,
|
|
|
|
time.wHour, time.wMinute, time.wSecond,
|
|
|
|
time.wMilliseconds );
|
2008-02-27 09:38:14 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled target type: %d\n", vt);
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2012-09-13 23:10:35 +02:00
|
|
|
static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits,
|
2013-11-20 23:39:31 +01:00
|
|
|
BOOL dest_signed, LONGLONG *res)
|
2012-09-13 23:10:35 +02:00
|
|
|
{
|
2013-11-20 23:39:31 +01:00
|
|
|
BOOL src_signed;
|
2012-09-13 23:10:35 +02:00
|
|
|
|
|
|
|
switch (pv->vt)
|
|
|
|
{
|
|
|
|
case VT_I1:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = TRUE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->cVal;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_UI1:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = FALSE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->bVal;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_I2:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = TRUE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->iVal;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_UI2:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = FALSE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->uiVal;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_I4:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = TRUE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->lVal;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_UI4:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = FALSE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->ulVal;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_I8:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = TRUE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->hVal.QuadPart;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_UI8:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = FALSE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->uhVal.QuadPart;
|
2012-09-13 23:10:35 +02:00
|
|
|
break;
|
|
|
|
case VT_EMPTY:
|
2013-11-20 23:39:31 +01:00
|
|
|
src_signed = FALSE;
|
2012-09-13 23:10:35 +02:00
|
|
|
*res = 0;
|
|
|
|
break;
|
2017-06-22 05:38:46 +02:00
|
|
|
case VT_LPSTR:
|
|
|
|
{
|
|
|
|
char *end;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = strtoll(pv->pszVal, &end, 0);
|
|
|
|
if (pv->pszVal == end)
|
2017-06-22 05:38:46 +02:00
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
src_signed = *res < 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VT_LPWSTR:
|
|
|
|
case VT_BSTR:
|
|
|
|
{
|
|
|
|
WCHAR *end;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = wcstol(pv->pwszVal, &end, 0);
|
|
|
|
if (pv->pwszVal == end)
|
2017-06-22 05:38:46 +02:00
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
src_signed = *res < 0;
|
|
|
|
break;
|
|
|
|
}
|
2019-02-07 09:33:14 +01:00
|
|
|
case VT_R8:
|
|
|
|
{
|
|
|
|
src_signed = TRUE;
|
2021-03-27 16:01:46 +01:00
|
|
|
*res = pv->dblVal;
|
2019-02-07 09:33:14 +01:00
|
|
|
break;
|
|
|
|
}
|
2012-09-13 23:10:35 +02:00
|
|
|
default:
|
|
|
|
FIXME("unhandled vt %d\n", pv->vt);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*res < 0 && src_signed != dest_signed)
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
|
|
|
|
|
|
|
if (dest_bits < 64)
|
|
|
|
{
|
|
|
|
if (dest_signed)
|
|
|
|
{
|
|
|
|
if (*res >= ((LONGLONG)1 << (dest_bits-1)) ||
|
|
|
|
*res < ((LONGLONG)-1 << (dest_bits-1)))
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((ULONGLONG)(*res) >= ((ULONGLONG)1 << dest_bits))
|
|
|
|
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-02-07 09:33:14 +01:00
|
|
|
HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", propvarIn, ret);
|
|
|
|
|
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
|
|
|
|
if (SUCCEEDED(hr)) *ret = (double)res;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-09-13 23:10:35 +02:00
|
|
|
HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", propvarIn, ret);
|
|
|
|
|
2013-11-20 23:39:31 +01:00
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 16, TRUE, &res);
|
2012-09-13 23:10:35 +02:00
|
|
|
if (SUCCEEDED(hr)) *ret = (SHORT)res;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", propvarIn, ret);
|
|
|
|
|
2013-11-20 23:39:31 +01:00
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 32, TRUE, &res);
|
2012-09-13 23:10:35 +02:00
|
|
|
if (SUCCEEDED(hr)) *ret = (LONG)res;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", propvarIn, ret);
|
|
|
|
|
2013-11-20 23:39:31 +01:00
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
|
2019-03-22 08:47:32 +01:00
|
|
|
if (SUCCEEDED(hr)) *ret = res;
|
2012-09-13 23:10:35 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", propvarIn, ret);
|
|
|
|
|
2013-11-20 23:39:31 +01:00
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 16, FALSE, &res);
|
2012-09-13 23:10:35 +02:00
|
|
|
if (SUCCEEDED(hr)) *ret = (USHORT)res;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", propvarIn, ret);
|
|
|
|
|
2013-11-20 23:39:31 +01:00
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 32, FALSE, &res);
|
2012-09-13 23:10:35 +02:00
|
|
|
if (SUCCEEDED(hr)) *ret = (ULONG)res;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", propvarIn, ret);
|
|
|
|
|
2013-11-20 23:39:31 +01:00
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 64, FALSE, &res);
|
2012-09-13 23:10:35 +02:00
|
|
|
if (SUCCEEDED(hr)) *ret = (ULONGLONG)res;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-09-22 09:00:46 +02:00
|
|
|
HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret)
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("%p,%p\n", propvarIn, ret);
|
|
|
|
|
|
|
|
*ret = FALSE;
|
|
|
|
|
|
|
|
switch (propvarIn->vt)
|
|
|
|
{
|
|
|
|
case VT_BOOL:
|
2021-03-27 16:01:46 +01:00
|
|
|
*ret = propvarIn->boolVal == VARIANT_TRUE;
|
2017-09-22 09:00:46 +02:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case VT_LPWSTR:
|
|
|
|
case VT_BSTR:
|
2021-03-27 16:01:46 +01:00
|
|
|
if (!propvarIn->pwszVal)
|
2017-09-22 09:00:46 +02:00
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
if (!lstrcmpiW(propvarIn->pwszVal, L"true") || !lstrcmpW(propvarIn->pwszVal, L"#TRUE#"))
|
2017-09-22 09:00:46 +02:00
|
|
|
{
|
|
|
|
*ret = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
if (!lstrcmpiW(propvarIn->pwszVal, L"false") || !lstrcmpW(propvarIn->pwszVal, L"#FALSE#"))
|
2017-09-22 09:00:46 +02:00
|
|
|
{
|
|
|
|
*ret = FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_LPSTR:
|
2021-03-27 16:01:46 +01:00
|
|
|
if (!propvarIn->pszVal)
|
2017-09-22 09:00:46 +02:00
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
if (!lstrcmpiA(propvarIn->pszVal, "true") || !lstrcmpA(propvarIn->pszVal, "#TRUE#"))
|
2017-09-22 09:00:46 +02:00
|
|
|
{
|
|
|
|
*ret = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
if (!lstrcmpiA(propvarIn->pszVal, "false") || !lstrcmpA(propvarIn->pszVal, "#FALSE#"))
|
2017-09-22 09:00:46 +02:00
|
|
|
{
|
|
|
|
*ret = FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-09-24 11:00:08 +02:00
|
|
|
hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
|
2017-09-22 09:00:46 +02:00
|
|
|
*ret = !!res;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-02-15 17:16:03 +01:00
|
|
|
HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %d)\n", propvarIn, ret, cb);
|
|
|
|
|
|
|
|
switch(propvarIn->vt)
|
|
|
|
{
|
|
|
|
case VT_VECTOR|VT_UI1:
|
2021-03-27 16:01:46 +01:00
|
|
|
if(cb > propvarIn->caub.cElems)
|
2019-02-15 17:16:03 +01:00
|
|
|
return E_FAIL;
|
2021-03-27 16:01:46 +01:00
|
|
|
memcpy(ret, propvarIn->caub.pElems, cb);
|
2019-02-15 17:16:03 +01:00
|
|
|
break;
|
|
|
|
case VT_ARRAY|VT_UI1:
|
|
|
|
FIXME("Unsupported type: VT_ARRAY|VT_UI1\n");
|
|
|
|
hr = E_NOTIMPL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("Unexpected type: %x\n", propvarIn->vt);
|
|
|
|
hr = E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-15 17:15:12 +01:00
|
|
|
HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR *stringW = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %d)\n", propvarIn, ret, cch);
|
|
|
|
|
|
|
|
ret[0] = '\0';
|
|
|
|
|
|
|
|
if(!cch)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = PropVariantToStringAlloc(propvarIn, &stringW);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if(lstrlenW(stringW) >= cch)
|
|
|
|
hr = STRSAFE_E_INSUFFICIENT_BUFFER;
|
|
|
|
lstrcpynW(ret, stringW, cch);
|
|
|
|
CoTaskMemFree(stringW);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-07-01 09:56:42 +02:00
|
|
|
HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret)
|
|
|
|
{
|
|
|
|
WCHAR *res = NULL;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("%p,%p semi-stub\n", propvarIn, ret);
|
|
|
|
|
|
|
|
switch(propvarIn->vt)
|
|
|
|
{
|
2019-02-15 17:14:54 +01:00
|
|
|
case VT_EMPTY:
|
2016-07-01 09:56:42 +02:00
|
|
|
case VT_NULL:
|
|
|
|
res = CoTaskMemAlloc(1*sizeof(WCHAR));
|
|
|
|
res[0] = '\0';
|
|
|
|
break;
|
2017-06-20 06:36:47 +02:00
|
|
|
|
2016-07-01 09:56:42 +02:00
|
|
|
case VT_LPSTR:
|
2021-03-27 16:01:46 +01:00
|
|
|
if(propvarIn->pszVal)
|
2016-07-01 09:56:42 +02:00
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, propvarIn->pszVal, -1, NULL, 0);
|
2016-07-01 09:56:42 +02:00
|
|
|
res = CoTaskMemAlloc(len*sizeof(WCHAR));
|
|
|
|
if(!res)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, propvarIn->pszVal, -1, res, len);
|
2016-07-01 09:56:42 +02:00
|
|
|
}
|
|
|
|
break;
|
2017-06-20 06:36:47 +02:00
|
|
|
|
|
|
|
case VT_LPWSTR:
|
|
|
|
case VT_BSTR:
|
2021-03-27 16:01:46 +01:00
|
|
|
if (propvarIn->pwszVal)
|
2017-06-20 06:36:47 +02:00
|
|
|
{
|
2021-03-27 16:01:46 +01:00
|
|
|
DWORD size = (lstrlenW(propvarIn->pwszVal) + 1) * sizeof(WCHAR);
|
2017-06-20 06:36:47 +02:00
|
|
|
res = CoTaskMemAlloc(size);
|
|
|
|
if(!res) return E_OUTOFMEMORY;
|
2021-03-27 16:01:46 +01:00
|
|
|
memcpy(res, propvarIn->pwszVal, size);
|
2017-06-20 06:36:47 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-07-01 09:56:42 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unsupported conversion (%d)\n", propvarIn->vt);
|
|
|
|
hr = E_FAIL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = res;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-02-17 23:33:54 +01:00
|
|
|
PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault)
|
|
|
|
{
|
|
|
|
if (propvarIn->vt == VT_BSTR)
|
|
|
|
{
|
2021-03-27 16:01:46 +01:00
|
|
|
if (propvarIn->bstrVal == NULL)
|
2020-10-03 20:28:24 +02:00
|
|
|
return L"";
|
2018-02-17 23:33:54 +01:00
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
return propvarIn->bstrVal;
|
2018-02-17 23:33:54 +01:00
|
|
|
}
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
if (propvarIn->vt == VT_LPWSTR && propvarIn->pwszVal != NULL)
|
|
|
|
return propvarIn->pwszVal;
|
2018-02-17 23:33:54 +01:00
|
|
|
|
|
|
|
return pszDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 09:38:14 +01:00
|
|
|
/******************************************************************
|
|
|
|
* PropVariantChangeType (PROPSYS.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
|
|
|
|
PROPVAR_CHANGE_FLAGS flags, VARTYPE vt)
|
|
|
|
{
|
2012-09-14 00:16:26 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2008-02-27 09:38:14 +01:00
|
|
|
FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc,
|
|
|
|
propvarSrc->vt, flags, vt);
|
|
|
|
|
2017-06-20 06:36:56 +02:00
|
|
|
if (vt == propvarSrc->vt)
|
2016-07-01 09:56:55 +02:00
|
|
|
return PropVariantCopy(ppropvarDest, propvarSrc);
|
|
|
|
|
2017-06-20 06:36:56 +02:00
|
|
|
if (propvarSrc->vt == VT_FILETIME)
|
2021-03-27 16:01:46 +01:00
|
|
|
return PROPVAR_ConvertFILETIME(&propvarSrc->filetime, ppropvarDest, vt);
|
2017-06-20 06:36:56 +02:00
|
|
|
|
2012-09-14 00:16:26 +02:00
|
|
|
switch (vt)
|
|
|
|
{
|
2017-06-20 06:36:35 +02:00
|
|
|
case VT_I1:
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
|
|
|
|
hr = PROPVAR_ConvertNumber(propvarSrc, 8, TRUE, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_I1;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->cVal = (char)res;
|
2017-06-20 06:36:35 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
case VT_UI1:
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
|
|
|
|
hr = PROPVAR_ConvertNumber(propvarSrc, 8, FALSE, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_UI1;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->bVal = (UCHAR)res;
|
2017-06-20 06:36:35 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-09-14 00:16:26 +02:00
|
|
|
case VT_I2:
|
|
|
|
{
|
|
|
|
SHORT res;
|
|
|
|
hr = PropVariantToInt16(propvarSrc, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_I2;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->iVal = res;
|
2012-09-14 00:16:26 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
case VT_UI2:
|
|
|
|
{
|
|
|
|
USHORT res;
|
|
|
|
hr = PropVariantToUInt16(propvarSrc, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_UI2;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->uiVal = res;
|
2012-09-14 00:16:26 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
case VT_I4:
|
|
|
|
{
|
|
|
|
LONG res;
|
|
|
|
hr = PropVariantToInt32(propvarSrc, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_I4;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->lVal = res;
|
2012-09-14 00:16:26 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
case VT_UI4:
|
|
|
|
{
|
|
|
|
ULONG res;
|
|
|
|
hr = PropVariantToUInt32(propvarSrc, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_UI4;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->ulVal = res;
|
2012-09-14 00:16:26 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
case VT_I8:
|
|
|
|
{
|
|
|
|
LONGLONG res;
|
|
|
|
hr = PropVariantToInt64(propvarSrc, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_I8;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->hVal.QuadPart = res;
|
2012-09-14 00:16:26 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
case VT_UI8:
|
|
|
|
{
|
|
|
|
ULONGLONG res;
|
|
|
|
hr = PropVariantToUInt64(propvarSrc, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_UI8;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->uhVal.QuadPart = res;
|
2012-09-14 00:16:26 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
2017-06-20 06:36:51 +02:00
|
|
|
|
2016-07-01 09:56:55 +02:00
|
|
|
case VT_LPWSTR:
|
2017-06-20 06:36:51 +02:00
|
|
|
case VT_BSTR:
|
2016-07-01 09:56:55 +02:00
|
|
|
{
|
|
|
|
WCHAR *res;
|
|
|
|
hr = PropVariantToStringAlloc(propvarSrc, &res);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
ppropvarDest->vt = VT_LPWSTR;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->pwszVal = res;
|
2016-07-01 09:56:55 +02:00
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
2012-09-14 00:16:26 +02:00
|
|
|
|
2017-06-20 06:37:00 +02:00
|
|
|
case VT_LPSTR:
|
|
|
|
{
|
|
|
|
WCHAR *resW;
|
|
|
|
hr = PropVariantToStringAlloc(propvarSrc, &resW);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
char *res;
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, resW, -1, NULL, 0, NULL, NULL);
|
|
|
|
res = CoTaskMemAlloc(len);
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, resW, -1, res, len, NULL, NULL);
|
|
|
|
ppropvarDest->vt = VT_LPSTR;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvarDest->pszVal = res;
|
2017-06-20 06:37:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
CoTaskMemFree(resW);
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-06-20 06:36:56 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled dest type: %d\n", vt);
|
|
|
|
return E_FAIL;
|
2008-02-27 09:38:14 +01:00
|
|
|
}
|
|
|
|
}
|
2011-09-16 11:20:07 +02:00
|
|
|
|
|
|
|
static void PROPVAR_GUIDToWSTR(REFGUID guid, WCHAR *str)
|
|
|
|
{
|
2020-10-03 20:28:24 +02:00
|
|
|
swprintf(str, 39, L"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", guid->Data1,
|
|
|
|
guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2],
|
|
|
|
guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
|
2011-09-16 11:20:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", guid, ppropvar);
|
|
|
|
|
|
|
|
if(!guid)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
ppropvar->vt = VT_LPWSTR;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvar->pwszVal = CoTaskMemAlloc(39*sizeof(WCHAR));
|
|
|
|
if(!ppropvar->pwszVal)
|
2011-09-16 11:20:07 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
PROPVAR_GUIDToWSTR(guid, ppropvar->pwszVal);
|
2011-09-16 11:20:07 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", guid, pvar);
|
|
|
|
|
|
|
|
if(!guid) {
|
|
|
|
FIXME("guid == NULL\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(pvar) = VT_BSTR;
|
|
|
|
V_BSTR(pvar) = SysAllocStringLen(NULL, 38);
|
|
|
|
if(!V_BSTR(pvar))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
PROPVAR_GUIDToWSTR(guid, V_BSTR(pvar));
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-09-16 11:20:37 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar)
|
|
|
|
{
|
|
|
|
TRACE("(%p %u %p)\n", pv, cb, ppropvar);
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvar->caub.pElems = CoTaskMemAlloc(cb);
|
|
|
|
if(!ppropvar->caub.pElems)
|
2011-09-16 11:20:37 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ppropvar->vt = VT_VECTOR|VT_UI1;
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvar->caub.cElems = cb;
|
|
|
|
memcpy(ppropvar->caub.pElems, pv, cb);
|
2011-09-16 11:20:37 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-16 15:48:41 +02:00
|
|
|
HRESULT WINAPI InitPropVariantFromCLSID(REFCLSID clsid, PROPVARIANT *ppropvar)
|
|
|
|
{
|
|
|
|
TRACE("(%s %p)\n", debugstr_guid(clsid), ppropvar);
|
|
|
|
|
2021-03-27 16:01:46 +01:00
|
|
|
ppropvar->puuid = CoTaskMemAlloc(sizeof(*ppropvar->puuid));
|
|
|
|
if(!ppropvar->puuid)
|
2018-09-16 15:48:41 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ppropvar->vt = VT_CLSID;
|
2021-03-27 16:01:46 +01:00
|
|
|
memcpy(ppropvar->puuid, clsid, sizeof(*ppropvar->puuid));
|
2018-09-16 15:48:41 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-16 11:20:37 +02:00
|
|
|
HRESULT WINAPI InitVariantFromBuffer(const VOID *pv, UINT cb, VARIANT *pvar)
|
|
|
|
{
|
|
|
|
SAFEARRAY *arr;
|
|
|
|
void *data;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %u %p)\n", pv, cb, pvar);
|
|
|
|
|
|
|
|
arr = SafeArrayCreateVector(VT_UI1, 0, cb);
|
|
|
|
if(!arr)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hres = SafeArrayAccessData(arr, &data);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SafeArrayDestroy(arr);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(data, pv, cb);
|
|
|
|
|
|
|
|
hres = SafeArrayUnaccessData(arr);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
SafeArrayDestroy(arr);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(pvar) = VT_ARRAY|VT_UI1;
|
|
|
|
V_ARRAY(pvar) = arr;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-09-19 10:56:05 +02:00
|
|
|
|
|
|
|
static inline DWORD PROPVAR_HexToNum(const WCHAR *hex)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if(hex[0]>='0' && hex[0]<='9')
|
|
|
|
ret = hex[0]-'0';
|
|
|
|
else if(hex[0]>='a' && hex[0]<='f')
|
|
|
|
ret = hex[0]-'a'+10;
|
|
|
|
else if(hex[0]>='A' && hex[0]<='F')
|
|
|
|
ret = hex[0]-'A'+10;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret <<= 4;
|
|
|
|
if(hex[1]>='0' && hex[1]<='9')
|
|
|
|
return ret + hex[1]-'0';
|
|
|
|
else if(hex[1]>='a' && hex[1]<='f')
|
|
|
|
return ret + hex[1]-'a'+10;
|
|
|
|
else if(hex[1]>='A' && hex[1]<='F')
|
|
|
|
return ret + hex[1]-'A'+10;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT PROPVAR_WCHARToGUID(const WCHAR *str, int len, GUID *guid)
|
|
|
|
{
|
|
|
|
DWORD i, val=0;
|
|
|
|
const WCHAR *p;
|
|
|
|
|
|
|
|
memset(guid, 0, sizeof(GUID));
|
|
|
|
|
|
|
|
if(len!=38 || str[0]!='{' || str[9]!='-' || str[14]!='-'
|
|
|
|
|| str[19]!='-' || str[24]!='-' || str[37]!='}') {
|
|
|
|
WARN("Error parsing %s\n", debugstr_w(str));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = str+1;
|
|
|
|
for(i=0; i<4 && val!=-1; i++) {
|
|
|
|
val = PROPVAR_HexToNum(p);
|
|
|
|
guid->Data1 = (guid->Data1<<8) + val;
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
for(i=0; i<2 && val!=-1; i++) {
|
|
|
|
val = PROPVAR_HexToNum(p);
|
|
|
|
guid->Data2 = (guid->Data2<<8) + val;
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
for(i=0; i<2 && val!=-1; i++) {
|
|
|
|
val = PROPVAR_HexToNum(p);
|
|
|
|
guid->Data3 = (guid->Data3<<8) + val;
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
for(i=0; i<8 && val!=-1; i++) {
|
|
|
|
if(i == 2)
|
|
|
|
p++;
|
|
|
|
|
|
|
|
val = guid->Data4[i] = PROPVAR_HexToNum(p);
|
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(val == -1) {
|
|
|
|
WARN("Error parsing %s\n", debugstr_w(str));
|
|
|
|
memset(guid, 0, sizeof(GUID));
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid)
|
|
|
|
{
|
|
|
|
TRACE("%p %p)\n", ppropvar, guid);
|
|
|
|
|
|
|
|
switch(ppropvar->vt) {
|
|
|
|
case VT_BSTR:
|
2021-03-27 16:01:46 +01:00
|
|
|
return PROPVAR_WCHARToGUID(ppropvar->bstrVal, SysStringLen(ppropvar->bstrVal), guid);
|
2011-09-19 10:56:05 +02:00
|
|
|
case VT_LPWSTR:
|
2021-03-27 16:01:46 +01:00
|
|
|
return PROPVAR_WCHARToGUID(ppropvar->pwszVal, lstrlenW(ppropvar->pwszVal), guid);
|
2019-02-15 17:15:39 +01:00
|
|
|
case VT_CLSID:
|
2021-03-27 16:01:46 +01:00
|
|
|
memcpy(guid, ppropvar->puuid, sizeof(*ppropvar->puuid));
|
2019-02-15 17:15:39 +01:00
|
|
|
return S_OK;
|
2011-09-19 10:56:05 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unsupported vt: %d\n", ppropvar->vt);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", pvar, guid);
|
|
|
|
|
|
|
|
switch(V_VT(pvar)) {
|
|
|
|
case VT_BSTR: {
|
|
|
|
HRESULT hres = PROPVAR_WCHARToGUID(V_BSTR(pvar), SysStringLen(V_BSTR(pvar)), guid);
|
|
|
|
if(hres == E_INVALIDARG)
|
|
|
|
return E_FAIL;
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unsupported vt: %d\n", V_VT(pvar));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
2012-09-13 21:33:11 +02:00
|
|
|
|
2013-11-20 23:39:31 +01:00
|
|
|
static BOOL isemptyornull(const PROPVARIANT *propvar)
|
2012-09-13 22:54:39 +02:00
|
|
|
{
|
|
|
|
if (propvar->vt == VT_EMPTY || propvar->vt == VT_NULL)
|
2013-11-20 23:39:31 +01:00
|
|
|
return TRUE;
|
2012-09-13 22:54:39 +02:00
|
|
|
if ((propvar->vt & VT_ARRAY) == VT_ARRAY)
|
|
|
|
{
|
|
|
|
int i;
|
2021-03-27 16:01:46 +01:00
|
|
|
for (i=0; i<propvar->parray->cDims; i++)
|
2012-09-13 22:54:39 +02:00
|
|
|
{
|
2021-03-27 16:01:46 +01:00
|
|
|
if (propvar->parray->rgsabound[i].cElements != 0)
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
}
|
2021-03-27 16:01:46 +01:00
|
|
|
return i == propvar->parray->cDims;
|
2012-09-13 22:54:39 +02:00
|
|
|
}
|
2019-03-15 11:56:42 +01:00
|
|
|
if (propvar->vt == VT_CLSID)
|
2021-03-27 16:01:46 +01:00
|
|
|
return !propvar->puuid;
|
2019-03-15 11:56:42 +01:00
|
|
|
|
2021-05-31 12:31:11 +02:00
|
|
|
if (propvar->vt & VT_VECTOR)
|
|
|
|
return !propvar->caub.cElems;
|
|
|
|
|
|
|
|
/* FIXME: byrefs, errors? */
|
2013-11-20 23:39:31 +01:00
|
|
|
return FALSE;
|
2012-09-13 22:54:39 +02:00
|
|
|
}
|
|
|
|
|
2012-09-13 21:33:11 +02:00
|
|
|
INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
|
|
|
|
PROPVAR_COMPARE_UNIT unit, PROPVAR_COMPARE_FLAGS flags)
|
|
|
|
{
|
2012-09-13 22:54:39 +02:00
|
|
|
const PROPVARIANT *propvar2_converted;
|
|
|
|
PROPVARIANT propvar2_static;
|
2021-05-31 12:31:11 +02:00
|
|
|
unsigned int count;
|
2012-09-13 22:54:39 +02:00
|
|
|
HRESULT hr;
|
|
|
|
INT res=-1;
|
|
|
|
|
|
|
|
TRACE("%p,%p,%x,%x\n", propvar1, propvar2, unit, flags);
|
|
|
|
|
|
|
|
if (isemptyornull(propvar1))
|
|
|
|
{
|
|
|
|
if (isemptyornull(propvar2))
|
|
|
|
return 0;
|
|
|
|
return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? 1 : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isemptyornull(propvar2))
|
|
|
|
return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? -1 : 1;
|
|
|
|
|
|
|
|
if (propvar1->vt != propvar2->vt)
|
|
|
|
{
|
|
|
|
hr = PropVariantChangeType(&propvar2_static, propvar2, 0, propvar1->vt);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
propvar2_converted = &propvar2_static;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
propvar2_converted = propvar2;
|
|
|
|
|
2019-03-15 11:56:43 +01:00
|
|
|
#define CMP_NUM_VALUE(var) do { \
|
2021-03-27 16:01:46 +01:00
|
|
|
if (propvar1->var > propvar2_converted->var) \
|
2012-09-13 22:54:39 +02:00
|
|
|
res = 1; \
|
2021-03-27 16:01:46 +01:00
|
|
|
else if (propvar1->var < propvar2_converted->var) \
|
2012-09-13 22:54:39 +02:00
|
|
|
res = -1; \
|
|
|
|
else \
|
|
|
|
res = 0; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
switch (propvar1->vt)
|
|
|
|
{
|
|
|
|
case VT_I1:
|
2019-03-15 11:56:43 +01:00
|
|
|
CMP_NUM_VALUE(cVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_UI1:
|
2019-03-15 11:56:43 +01:00
|
|
|
CMP_NUM_VALUE(bVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_I2:
|
2019-03-15 11:56:43 +01:00
|
|
|
CMP_NUM_VALUE(iVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_UI2:
|
2019-03-15 11:56:43 +01:00
|
|
|
CMP_NUM_VALUE(uiVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_I4:
|
2019-03-15 11:56:43 +01:00
|
|
|
CMP_NUM_VALUE(lVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_UI4:
|
2021-11-08 15:08:15 +01:00
|
|
|
CMP_NUM_VALUE(ulVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_I8:
|
2019-03-15 11:56:43 +01:00
|
|
|
CMP_NUM_VALUE(hVal.QuadPart);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_UI8:
|
2019-03-15 11:56:43 +01:00
|
|
|
CMP_NUM_VALUE(uhVal.QuadPart);
|
|
|
|
break;
|
|
|
|
case VT_R4:
|
|
|
|
CMP_NUM_VALUE(fltVal);
|
|
|
|
break;
|
|
|
|
case VT_R8:
|
|
|
|
CMP_NUM_VALUE(dblVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
|
|
|
case VT_BSTR:
|
2017-06-22 05:38:46 +02:00
|
|
|
case VT_LPWSTR:
|
|
|
|
/* FIXME: Use other string flags. */
|
|
|
|
if (flags & (PVCF_USESTRCMPI | PVCF_USESTRCMPIC))
|
2021-03-27 16:01:46 +01:00
|
|
|
res = lstrcmpiW(propvar1->bstrVal, propvar2_converted->bstrVal);
|
2017-06-22 05:38:46 +02:00
|
|
|
else
|
2021-03-27 16:01:46 +01:00
|
|
|
res = lstrcmpW(propvar1->bstrVal, propvar2_converted->bstrVal);
|
2017-06-22 05:38:46 +02:00
|
|
|
break;
|
|
|
|
case VT_LPSTR:
|
|
|
|
/* FIXME: Use other string flags. */
|
|
|
|
if (flags & (PVCF_USESTRCMPI | PVCF_USESTRCMPIC))
|
2021-03-27 16:01:46 +01:00
|
|
|
res = lstrcmpiA(propvar1->pszVal, propvar2_converted->pszVal);
|
2017-06-22 05:38:46 +02:00
|
|
|
else
|
2021-03-27 16:01:46 +01:00
|
|
|
res = lstrcmpA(propvar1->pszVal, propvar2_converted->pszVal);
|
2012-09-13 22:54:39 +02:00
|
|
|
break;
|
2019-03-15 11:56:42 +01:00
|
|
|
case VT_CLSID:
|
2021-03-27 16:01:46 +01:00
|
|
|
res = memcmp(propvar1->puuid, propvar2->puuid, sizeof(*propvar1->puuid));
|
2019-03-15 11:56:42 +01:00
|
|
|
if (res) res = res > 0 ? 1 : -1;
|
|
|
|
break;
|
2021-05-31 12:31:11 +02:00
|
|
|
case VT_VECTOR | VT_UI1:
|
|
|
|
count = min(propvar1->caub.cElems, propvar2->caub.cElems);
|
|
|
|
res = count ? memcmp(propvar1->caub.pElems, propvar2->caub.pElems, sizeof(*propvar1->caub.pElems) * count) : 0;
|
|
|
|
if (res) res = res > 0 ? 1 : -1;
|
|
|
|
if (!res && propvar1->caub.cElems != propvar2->caub.cElems)
|
|
|
|
res = propvar1->caub.cElems > propvar2->caub.cElems ? 1 : -1;
|
|
|
|
break;
|
2012-09-13 22:54:39 +02:00
|
|
|
default:
|
2019-03-15 11:56:42 +01:00
|
|
|
FIXME("vartype %#x not handled\n", propvar1->vt);
|
2012-09-13 22:54:39 +02:00
|
|
|
res = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (propvar2_converted == &propvar2_static)
|
|
|
|
PropVariantClear(&propvar2_static);
|
2012-09-13 21:33:11 +02:00
|
|
|
|
2012-09-13 22:54:39 +02:00
|
|
|
return res;
|
2012-09-13 21:33:11 +02:00
|
|
|
}
|