1 /* 2 * Copyright 2008 James Hawkins for CodeWeavers 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17 */ 18 19 #ifndef __WINE_PROPVARUTIL_H 20 #define __WINE_PROPVARUTIL_H 21 22 #include <shtypes.h> 23 #include <shlwapi.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 enum tagPROPVAR_CHANGE_FLAGS 30 { 31 PVCHF_DEFAULT = 0x00000000, 32 PVCHF_NOVALUEPROP = 0x00000001, 33 PVCHF_ALPHABOOL = 0x00000002, 34 PVCHF_NOUSEROVERRIDE = 0x00000004, 35 PVCHF_LOCALBOOL = 0x00000008, 36 PVCHF_NOHEXSTRING = 0x00000010, 37 }; 38 39 typedef int PROPVAR_CHANGE_FLAGS; 40 41 enum tagPROPVAR_COMPARE_UNIT 42 { 43 PVCU_DEFAULT = 0x00000000, 44 PVCU_SECOND = 0x00000001, 45 PVCU_MINUTE = 0x00000002, 46 PVCU_HOUR = 0x00000003, 47 PVCU_DAY = 0x00000004, 48 PVCU_MONTH = 0x00000005, 49 PVCU_YEAR = 0x00000006, 50 }; 51 52 typedef int PROPVAR_COMPARE_UNIT; 53 54 enum tagPROPVAR_COMPARE_FLAGS 55 { 56 PVCF_DEFAULT = 0x00000000, 57 PVCF_TREATEMPTYASGREATERTHAN = 0x00000001, 58 PVCF_USESTRCMP = 0x00000002, 59 PVCF_USESTRCMPC = 0x00000004, 60 PVCF_USESTRCMPI = 0x00000008, 61 PVCF_USESTRCMPIC = 0x00000010, 62 }; 63 64 typedef int PROPVAR_COMPARE_FLAGS; 65 66 HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc, 67 PROPVAR_CHANGE_FLAGS flags, VARTYPE vt); 68 HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar); 69 HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar); 70 HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar); 71 HRESULT WINAPI InitPropVariantFromCLSID(REFCLSID clsid, PROPVARIANT *ppropvar); 72 HRESULT WINAPI InitVariantFromBuffer(const VOID *pv, UINT cb, VARIANT *pvar); 73 HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid); 74 HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid); 75 INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2, 76 PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags); 77 78 HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret); 79 HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret); 80 HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret); 81 HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret); 82 HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret); 83 HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret); 84 HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret); 85 HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret); 86 HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb); 87 HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch); 88 PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault); 89 90 HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret); 91 92 #ifdef __cplusplus 93 94 HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar); 95 HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar); 96 HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar); 97 98 #ifndef NO_PROPVAR_INLINES 99 100 inline HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar) 101 { 102 ppropvar->vt = VT_BOOL; 103 ppropvar->boolVal = fVal ? VARIANT_TRUE : VARIANT_FALSE; 104 return S_OK; 105 } 106 107 inline HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar) 108 { 109 HRESULT hres; 110 111 hres = SHStrDupW(psz, &ppropvar->pwszVal); 112 if(SUCCEEDED(hres)) 113 ppropvar->vt = VT_LPWSTR; 114 else 115 PropVariantInit(ppropvar); 116 117 return hres; 118 } 119 120 inline HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar) 121 { 122 ppropvar->vt = VT_I8; 123 ppropvar->hVal.QuadPart = llVal; 124 return S_OK; 125 } 126 127 #endif /* NO_PROPVAR_INLINES */ 128 #endif /* __cplusplus */ 129 130 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif /* __WINE_PROPVARUTIL_H */ 136