wevtapi: Add EvtOpenLog stub.
[wine.git] / dlls / propsys / propvar.c
blob3e3b502675399c9500e22305d46df4cfc29ae66e
1 /*
2 * PropVariant implementation
4 * Copyright 2008 James Hawkins for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
28 #define NONAMELESSUNION
30 #include "windef.h"
31 #include "winbase.h"
32 #include "winerror.h"
33 #include "winreg.h"
34 #include "winuser.h"
35 #include "shlobj.h"
36 #include "propvarutil.h"
38 #include "wine/debug.h"
39 #include "wine/unicode.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(propsys);
43 static HRESULT PROPVAR_ConvertFILETIME(const FILETIME *ft, PROPVARIANT *ppropvarDest, VARTYPE vt)
45 SYSTEMTIME time;
47 FileTimeToSystemTime(ft, &time);
49 switch (vt)
51 case VT_LPSTR:
52 ppropvarDest->u.pszVal = HeapAlloc(GetProcessHeap(), 0, 64);
53 if (!ppropvarDest->u.pszVal)
54 return E_OUTOFMEMORY;
56 sprintf( ppropvarDest->u.pszVal, "%04d/%02d/%02d:%02d:%02d:%02d.%03d",
57 time.wYear, time.wMonth, time.wDay,
58 time.wHour, time.wMinute, time.wSecond,
59 time.wMilliseconds );
61 return S_OK;
63 default:
64 FIXME("Unhandled target type: %d\n", vt);
67 return E_FAIL;
70 static HRESULT PROPVAR_ConvertNumber(REFPROPVARIANT pv, int dest_bits,
71 BOOL dest_signed, LONGLONG *res)
73 BOOL src_signed;
75 switch (pv->vt)
77 case VT_I1:
78 src_signed = TRUE;
79 *res = pv->u.cVal;
80 break;
81 case VT_UI1:
82 src_signed = FALSE;
83 *res = pv->u.bVal;
84 break;
85 case VT_I2:
86 src_signed = TRUE;
87 *res = pv->u.iVal;
88 break;
89 case VT_UI2:
90 src_signed = FALSE;
91 *res = pv->u.uiVal;
92 break;
93 case VT_I4:
94 src_signed = TRUE;
95 *res = pv->u.lVal;
96 break;
97 case VT_UI4:
98 src_signed = FALSE;
99 *res = pv->u.ulVal;
100 break;
101 case VT_I8:
102 src_signed = TRUE;
103 *res = pv->u.hVal.QuadPart;
104 break;
105 case VT_UI8:
106 src_signed = FALSE;
107 *res = pv->u.uhVal.QuadPart;
108 break;
109 case VT_EMPTY:
110 src_signed = FALSE;
111 *res = 0;
112 break;
113 case VT_LPSTR:
115 char *end;
116 *res = strtoll(pv->u.pszVal, &end, 0);
117 if (pv->u.pszVal == end)
118 return DISP_E_TYPEMISMATCH;
119 src_signed = *res < 0;
120 break;
122 case VT_LPWSTR:
123 case VT_BSTR:
125 WCHAR *end;
126 *res = strtolW(pv->u.pwszVal, &end, 0);
127 if (pv->u.pwszVal == end)
128 return DISP_E_TYPEMISMATCH;
129 src_signed = *res < 0;
130 break;
132 default:
133 FIXME("unhandled vt %d\n", pv->vt);
134 return E_NOTIMPL;
137 if (*res < 0 && src_signed != dest_signed)
138 return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
140 if (dest_bits < 64)
142 if (dest_signed)
144 if (*res >= ((LONGLONG)1 << (dest_bits-1)) ||
145 *res < ((LONGLONG)-1 << (dest_bits-1)))
146 return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
148 else
150 if ((ULONGLONG)(*res) >= ((ULONGLONG)1 << dest_bits))
151 return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
155 return S_OK;
158 HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret)
160 LONGLONG res;
161 HRESULT hr;
163 TRACE("%p,%p\n", propvarIn, ret);
165 hr = PROPVAR_ConvertNumber(propvarIn, 16, TRUE, &res);
166 if (SUCCEEDED(hr)) *ret = (SHORT)res;
167 return hr;
170 HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret)
172 LONGLONG res;
173 HRESULT hr;
175 TRACE("%p,%p\n", propvarIn, ret);
177 hr = PROPVAR_ConvertNumber(propvarIn, 32, TRUE, &res);
178 if (SUCCEEDED(hr)) *ret = (LONG)res;
179 return hr;
182 HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret)
184 LONGLONG res;
185 HRESULT hr;
187 TRACE("%p,%p\n", propvarIn, ret);
189 hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
190 if (SUCCEEDED(hr)) *ret = (LONGLONG)res;
191 return hr;
194 HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret)
196 LONGLONG res;
197 HRESULT hr;
199 TRACE("%p,%p\n", propvarIn, ret);
201 hr = PROPVAR_ConvertNumber(propvarIn, 16, FALSE, &res);
202 if (SUCCEEDED(hr)) *ret = (USHORT)res;
203 return hr;
206 HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret)
208 LONGLONG res;
209 HRESULT hr;
211 TRACE("%p,%p\n", propvarIn, ret);
213 hr = PROPVAR_ConvertNumber(propvarIn, 32, FALSE, &res);
214 if (SUCCEEDED(hr)) *ret = (ULONG)res;
215 return hr;
218 HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
220 LONGLONG res;
221 HRESULT hr;
223 TRACE("%p,%p\n", propvarIn, ret);
225 hr = PROPVAR_ConvertNumber(propvarIn, 64, FALSE, &res);
226 if (SUCCEEDED(hr)) *ret = (ULONGLONG)res;
227 return hr;
230 HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret)
232 static const WCHAR trueW[] = {'t','r','u','e',0};
233 static const WCHAR falseW[] = {'f','a','l','s','e',0};
234 static const WCHAR true2W[] = {'#','T','R','U','E','#',0};
235 static const WCHAR false2W[] = {'#','F','A','L','S','E','#',0};
236 LONGLONG res;
237 HRESULT hr;
239 TRACE("%p,%p\n", propvarIn, ret);
241 *ret = FALSE;
243 switch (propvarIn->vt)
245 case VT_BOOL:
246 *ret = propvarIn->u.boolVal == VARIANT_TRUE;
247 return S_OK;
249 case VT_LPWSTR:
250 case VT_BSTR:
251 if (!propvarIn->u.pwszVal)
252 return DISP_E_TYPEMISMATCH;
254 if (!lstrcmpiW(propvarIn->u.pwszVal, trueW) || !lstrcmpW(propvarIn->u.pwszVal, true2W))
256 *ret = TRUE;
257 return S_OK;
260 if (!lstrcmpiW(propvarIn->u.pwszVal, falseW) || !lstrcmpW(propvarIn->u.pwszVal, false2W))
262 *ret = FALSE;
263 return S_OK;
265 break;
267 case VT_LPSTR:
268 if (!propvarIn->u.pszVal)
269 return DISP_E_TYPEMISMATCH;
271 if (!lstrcmpiA(propvarIn->u.pszVal, "true") || !lstrcmpA(propvarIn->u.pszVal, "#TRUE#"))
273 *ret = TRUE;
274 return S_OK;
277 if (!lstrcmpiA(propvarIn->u.pszVal, "false") || !lstrcmpA(propvarIn->u.pszVal, "#FALSE#"))
279 *ret = FALSE;
280 return S_OK;
282 break;
285 hr = PROPVAR_ConvertNumber(propvarIn, 64, TRUE, &res);
286 *ret = !!res;
287 return hr;
290 HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret)
292 WCHAR *res = NULL;
293 HRESULT hr = S_OK;
295 TRACE("%p,%p semi-stub\n", propvarIn, ret);
297 switch(propvarIn->vt)
299 case VT_NULL:
300 res = CoTaskMemAlloc(1*sizeof(WCHAR));
301 res[0] = '\0';
302 break;
304 case VT_LPSTR:
305 if(propvarIn->u.pszVal)
307 DWORD len;
309 len = MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, NULL, 0);
310 res = CoTaskMemAlloc(len*sizeof(WCHAR));
311 if(!res)
312 return E_OUTOFMEMORY;
314 MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, res, len);
316 break;
318 case VT_LPWSTR:
319 case VT_BSTR:
320 if (propvarIn->u.pwszVal)
322 DWORD size = (lstrlenW(propvarIn->u.pwszVal) + 1) * sizeof(WCHAR);
323 res = CoTaskMemAlloc(size);
324 if(!res) return E_OUTOFMEMORY;
325 memcpy(res, propvarIn->u.pwszVal, size);
327 break;
329 default:
330 FIXME("Unsupported conversion (%d)\n", propvarIn->vt);
331 hr = E_FAIL;
332 break;
335 *ret = res;
337 return hr;
340 /******************************************************************
341 * PropVariantChangeType (PROPSYS.@)
343 HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
344 PROPVAR_CHANGE_FLAGS flags, VARTYPE vt)
346 HRESULT hr;
348 FIXME("(%p, %p, %d, %d, %d): semi-stub!\n", ppropvarDest, propvarSrc,
349 propvarSrc->vt, flags, vt);
351 if (vt == propvarSrc->vt)
352 return PropVariantCopy(ppropvarDest, propvarSrc);
354 if (propvarSrc->vt == VT_FILETIME)
355 return PROPVAR_ConvertFILETIME(&propvarSrc->u.filetime, ppropvarDest, vt);
357 switch (vt)
359 case VT_I1:
361 LONGLONG res;
363 hr = PROPVAR_ConvertNumber(propvarSrc, 8, TRUE, &res);
364 if (SUCCEEDED(hr))
366 ppropvarDest->vt = VT_I1;
367 ppropvarDest->u.cVal = (char)res;
369 return hr;
372 case VT_UI1:
374 LONGLONG res;
376 hr = PROPVAR_ConvertNumber(propvarSrc, 8, FALSE, &res);
377 if (SUCCEEDED(hr))
379 ppropvarDest->vt = VT_UI1;
380 ppropvarDest->u.bVal = (UCHAR)res;
382 return hr;
385 case VT_I2:
387 SHORT res;
388 hr = PropVariantToInt16(propvarSrc, &res);
389 if (SUCCEEDED(hr))
391 ppropvarDest->vt = VT_I2;
392 ppropvarDest->u.iVal = res;
394 return hr;
396 case VT_UI2:
398 USHORT res;
399 hr = PropVariantToUInt16(propvarSrc, &res);
400 if (SUCCEEDED(hr))
402 ppropvarDest->vt = VT_UI2;
403 ppropvarDest->u.uiVal = res;
405 return hr;
407 case VT_I4:
409 LONG res;
410 hr = PropVariantToInt32(propvarSrc, &res);
411 if (SUCCEEDED(hr))
413 ppropvarDest->vt = VT_I4;
414 ppropvarDest->u.lVal = res;
416 return hr;
418 case VT_UI4:
420 ULONG res;
421 hr = PropVariantToUInt32(propvarSrc, &res);
422 if (SUCCEEDED(hr))
424 ppropvarDest->vt = VT_UI4;
425 ppropvarDest->u.ulVal = res;
427 return hr;
429 case VT_I8:
431 LONGLONG res;
432 hr = PropVariantToInt64(propvarSrc, &res);
433 if (SUCCEEDED(hr))
435 ppropvarDest->vt = VT_I8;
436 ppropvarDest->u.hVal.QuadPart = res;
438 return hr;
440 case VT_UI8:
442 ULONGLONG res;
443 hr = PropVariantToUInt64(propvarSrc, &res);
444 if (SUCCEEDED(hr))
446 ppropvarDest->vt = VT_UI8;
447 ppropvarDest->u.uhVal.QuadPart = res;
449 return hr;
452 case VT_LPWSTR:
453 case VT_BSTR:
455 WCHAR *res;
456 hr = PropVariantToStringAlloc(propvarSrc, &res);
457 if (SUCCEEDED(hr))
459 ppropvarDest->vt = VT_LPWSTR;
460 ppropvarDest->u.pwszVal = res;
462 return hr;
465 case VT_LPSTR:
467 WCHAR *resW;
468 hr = PropVariantToStringAlloc(propvarSrc, &resW);
469 if (SUCCEEDED(hr))
471 char *res;
472 DWORD len;
474 len = WideCharToMultiByte(CP_ACP, 0, resW, -1, NULL, 0, NULL, NULL);
475 res = CoTaskMemAlloc(len);
476 if (res)
478 WideCharToMultiByte(CP_ACP, 0, resW, -1, res, len, NULL, NULL);
479 ppropvarDest->vt = VT_LPSTR;
480 ppropvarDest->u.pszVal = res;
482 else
483 hr = E_OUTOFMEMORY;
485 CoTaskMemFree(resW);
487 return hr;
490 default:
491 FIXME("Unhandled dest type: %d\n", vt);
492 return E_FAIL;
496 static void PROPVAR_GUIDToWSTR(REFGUID guid, WCHAR *str)
498 static const WCHAR format[] = {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X',
499 '-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X',
500 '%','0','2','X','%','0','2','X','%','0','2','X','}',0};
502 sprintfW(str, format, guid->Data1, guid->Data2, guid->Data3,
503 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
504 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
507 HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar)
509 TRACE("(%p %p)\n", guid, ppropvar);
511 if(!guid)
512 return E_FAIL;
514 ppropvar->vt = VT_LPWSTR;
515 ppropvar->u.pwszVal = CoTaskMemAlloc(39*sizeof(WCHAR));
516 if(!ppropvar->u.pwszVal)
517 return E_OUTOFMEMORY;
519 PROPVAR_GUIDToWSTR(guid, ppropvar->u.pwszVal);
520 return S_OK;
523 HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar)
525 TRACE("(%p %p)\n", guid, pvar);
527 if(!guid) {
528 FIXME("guid == NULL\n");
529 return E_FAIL;
532 V_VT(pvar) = VT_BSTR;
533 V_BSTR(pvar) = SysAllocStringLen(NULL, 38);
534 if(!V_BSTR(pvar))
535 return E_OUTOFMEMORY;
537 PROPVAR_GUIDToWSTR(guid, V_BSTR(pvar));
538 return S_OK;
541 HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar)
543 TRACE("(%p %u %p)\n", pv, cb, ppropvar);
545 ppropvar->u.caub.pElems = CoTaskMemAlloc(cb);
546 if(!ppropvar->u.caub.pElems)
547 return E_OUTOFMEMORY;
549 ppropvar->vt = VT_VECTOR|VT_UI1;
550 ppropvar->u.caub.cElems = cb;
551 memcpy(ppropvar->u.caub.pElems, pv, cb);
552 return S_OK;
555 HRESULT WINAPI InitVariantFromBuffer(const VOID *pv, UINT cb, VARIANT *pvar)
557 SAFEARRAY *arr;
558 void *data;
559 HRESULT hres;
561 TRACE("(%p %u %p)\n", pv, cb, pvar);
563 arr = SafeArrayCreateVector(VT_UI1, 0, cb);
564 if(!arr)
565 return E_OUTOFMEMORY;
567 hres = SafeArrayAccessData(arr, &data);
568 if(FAILED(hres)) {
569 SafeArrayDestroy(arr);
570 return hres;
573 memcpy(data, pv, cb);
575 hres = SafeArrayUnaccessData(arr);
576 if(FAILED(hres)) {
577 SafeArrayDestroy(arr);
578 return hres;
581 V_VT(pvar) = VT_ARRAY|VT_UI1;
582 V_ARRAY(pvar) = arr;
583 return S_OK;
586 static inline DWORD PROPVAR_HexToNum(const WCHAR *hex)
588 DWORD ret;
590 if(hex[0]>='0' && hex[0]<='9')
591 ret = hex[0]-'0';
592 else if(hex[0]>='a' && hex[0]<='f')
593 ret = hex[0]-'a'+10;
594 else if(hex[0]>='A' && hex[0]<='F')
595 ret = hex[0]-'A'+10;
596 else
597 return -1;
599 ret <<= 4;
600 if(hex[1]>='0' && hex[1]<='9')
601 return ret + hex[1]-'0';
602 else if(hex[1]>='a' && hex[1]<='f')
603 return ret + hex[1]-'a'+10;
604 else if(hex[1]>='A' && hex[1]<='F')
605 return ret + hex[1]-'A'+10;
606 else
607 return -1;
610 static inline HRESULT PROPVAR_WCHARToGUID(const WCHAR *str, int len, GUID *guid)
612 DWORD i, val=0;
613 const WCHAR *p;
615 memset(guid, 0, sizeof(GUID));
617 if(len!=38 || str[0]!='{' || str[9]!='-' || str[14]!='-'
618 || str[19]!='-' || str[24]!='-' || str[37]!='}') {
619 WARN("Error parsing %s\n", debugstr_w(str));
620 return E_INVALIDARG;
623 p = str+1;
624 for(i=0; i<4 && val!=-1; i++) {
625 val = PROPVAR_HexToNum(p);
626 guid->Data1 = (guid->Data1<<8) + val;
627 p += 2;
629 p++;
630 for(i=0; i<2 && val!=-1; i++) {
631 val = PROPVAR_HexToNum(p);
632 guid->Data2 = (guid->Data2<<8) + val;
633 p += 2;
635 p++;
636 for(i=0; i<2 && val!=-1; i++) {
637 val = PROPVAR_HexToNum(p);
638 guid->Data3 = (guid->Data3<<8) + val;
639 p += 2;
641 p++;
642 for(i=0; i<8 && val!=-1; i++) {
643 if(i == 2)
644 p++;
646 val = guid->Data4[i] = PROPVAR_HexToNum(p);
647 p += 2;
650 if(val == -1) {
651 WARN("Error parsing %s\n", debugstr_w(str));
652 memset(guid, 0, sizeof(GUID));
653 return E_INVALIDARG;
655 return S_OK;
658 HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid)
660 TRACE("%p %p)\n", ppropvar, guid);
662 switch(ppropvar->vt) {
663 case VT_BSTR:
664 return PROPVAR_WCHARToGUID(ppropvar->u.bstrVal, SysStringLen(ppropvar->u.bstrVal), guid);
665 case VT_LPWSTR:
666 return PROPVAR_WCHARToGUID(ppropvar->u.pwszVal, strlenW(ppropvar->u.pwszVal), guid);
668 default:
669 FIXME("unsupported vt: %d\n", ppropvar->vt);
670 return E_NOTIMPL;
674 HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid)
676 TRACE("(%p %p)\n", pvar, guid);
678 switch(V_VT(pvar)) {
679 case VT_BSTR: {
680 HRESULT hres = PROPVAR_WCHARToGUID(V_BSTR(pvar), SysStringLen(V_BSTR(pvar)), guid);
681 if(hres == E_INVALIDARG)
682 return E_FAIL;
683 return hres;
686 default:
687 FIXME("unsupported vt: %d\n", V_VT(pvar));
688 return E_NOTIMPL;
692 static BOOL isemptyornull(const PROPVARIANT *propvar)
694 if (propvar->vt == VT_EMPTY || propvar->vt == VT_NULL)
695 return TRUE;
696 if ((propvar->vt & VT_ARRAY) == VT_ARRAY)
698 int i;
699 for (i=0; i<propvar->u.parray->cDims; i++)
701 if (propvar->u.parray->rgsabound[i].cElements != 0)
702 break;
704 return i == propvar->u.parray->cDims;
706 /* FIXME: vectors, byrefs, errors? */
707 return FALSE;
710 INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
711 PROPVAR_COMPARE_UNIT unit, PROPVAR_COMPARE_FLAGS flags)
713 const PROPVARIANT *propvar2_converted;
714 PROPVARIANT propvar2_static;
715 HRESULT hr;
716 INT res=-1;
718 TRACE("%p,%p,%x,%x\n", propvar1, propvar2, unit, flags);
720 if (isemptyornull(propvar1))
722 if (isemptyornull(propvar2))
723 return 0;
724 return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? 1 : -1;
727 if (isemptyornull(propvar2))
728 return (flags & PVCF_TREATEMPTYASGREATERTHAN) ? -1 : 1;
730 if (propvar1->vt != propvar2->vt)
732 hr = PropVariantChangeType(&propvar2_static, propvar2, 0, propvar1->vt);
734 if (FAILED(hr))
735 return -1;
737 propvar2_converted = &propvar2_static;
739 else
740 propvar2_converted = propvar2;
742 #define CMP_INT_VALUE(var) do { \
743 if (propvar1->u.var > propvar2_converted->u.var) \
744 res = 1; \
745 else if (propvar1->u.var < propvar2_converted->u.var) \
746 res = -1; \
747 else \
748 res = 0; \
749 } while (0)
751 switch (propvar1->vt)
753 case VT_I1:
754 CMP_INT_VALUE(cVal);
755 break;
756 case VT_UI1:
757 CMP_INT_VALUE(bVal);
758 break;
759 case VT_I2:
760 CMP_INT_VALUE(iVal);
761 break;
762 case VT_UI2:
763 CMP_INT_VALUE(uiVal);
764 break;
765 case VT_I4:
766 CMP_INT_VALUE(lVal);
767 break;
768 case VT_UI4:
769 CMP_INT_VALUE(uiVal);
770 break;
771 case VT_I8:
772 CMP_INT_VALUE(hVal.QuadPart);
773 break;
774 case VT_UI8:
775 CMP_INT_VALUE(uhVal.QuadPart);
776 break;
777 case VT_BSTR:
778 case VT_LPWSTR:
779 /* FIXME: Use other string flags. */
780 if (flags & (PVCF_USESTRCMPI | PVCF_USESTRCMPIC))
781 res = lstrcmpiW(propvar1->u.bstrVal, propvar2_converted->u.bstrVal);
782 else
783 res = lstrcmpW(propvar1->u.bstrVal, propvar2_converted->u.bstrVal);
784 break;
785 case VT_LPSTR:
786 /* FIXME: Use other string flags. */
787 if (flags & (PVCF_USESTRCMPI | PVCF_USESTRCMPIC))
788 res = lstrcmpiA(propvar1->u.pszVal, propvar2_converted->u.pszVal);
789 else
790 res = lstrcmpA(propvar1->u.pszVal, propvar2_converted->u.pszVal);
791 break;
792 default:
793 FIXME("vartype %d not handled\n", propvar1->vt);
794 res = -1;
795 break;
798 if (propvar2_converted == &propvar2_static)
799 PropVariantClear(&propvar2_static);
801 return res;