[1166] | 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 | #ifndef WINE_NTSTATUS_DECLARED
|
---|
| 26 | #define WINE_NTSTATUS_DECLARED
|
---|
| 27 | typedef LONG NTSTATUS;
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
| 30 | #ifdef __cplusplus
|
---|
| 31 | extern "C" {
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
| 34 | enum tagPROPVAR_CHANGE_FLAGS
|
---|
| 35 | {
|
---|
| 36 | PVCHF_DEFAULT = 0x00000000,
|
---|
| 37 | PVCHF_NOVALUEPROP = 0x00000001,
|
---|
| 38 | PVCHF_ALPHABOOL = 0x00000002,
|
---|
| 39 | PVCHF_NOUSEROVERRIDE = 0x00000004,
|
---|
| 40 | PVCHF_LOCALBOOL = 0x00000008,
|
---|
| 41 | PVCHF_NOHEXSTRING = 0x00000010,
|
---|
| 42 | };
|
---|
| 43 |
|
---|
| 44 | typedef int PROPVAR_CHANGE_FLAGS;
|
---|
| 45 |
|
---|
| 46 | enum tagPROPVAR_COMPARE_UNIT
|
---|
| 47 | {
|
---|
| 48 | PVCU_DEFAULT = 0x00000000,
|
---|
| 49 | PVCU_SECOND = 0x00000001,
|
---|
| 50 | PVCU_MINUTE = 0x00000002,
|
---|
| 51 | PVCU_HOUR = 0x00000003,
|
---|
| 52 | PVCU_DAY = 0x00000004,
|
---|
| 53 | PVCU_MONTH = 0x00000005,
|
---|
| 54 | PVCU_YEAR = 0x00000006,
|
---|
| 55 | };
|
---|
| 56 |
|
---|
| 57 | typedef int PROPVAR_COMPARE_UNIT;
|
---|
| 58 |
|
---|
| 59 | enum tagPROPVAR_COMPARE_FLAGS
|
---|
| 60 | {
|
---|
| 61 | PVCF_DEFAULT = 0x00000000,
|
---|
| 62 | PVCF_TREATEMPTYASGREATERTHAN = 0x00000001,
|
---|
| 63 | PVCF_USESTRCMP = 0x00000002,
|
---|
| 64 | PVCF_USESTRCMPC = 0x00000004,
|
---|
| 65 | PVCF_USESTRCMPI = 0x00000008,
|
---|
| 66 | PVCF_USESTRCMPIC = 0x00000010,
|
---|
| 67 | };
|
---|
| 68 |
|
---|
| 69 | typedef int PROPVAR_COMPARE_FLAGS;
|
---|
| 70 |
|
---|
| 71 | HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
|
---|
| 72 | PROPVAR_CHANGE_FLAGS flags, VARTYPE vt);
|
---|
| 73 | HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar);
|
---|
| 74 | HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar);
|
---|
| 75 | HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar);
|
---|
| 76 | HRESULT WINAPI InitPropVariantFromCLSID(REFCLSID clsid, PROPVARIANT *ppropvar);
|
---|
| 77 | HRESULT WINAPI InitVariantFromBuffer(const VOID *pv, UINT cb, VARIANT *pvar);
|
---|
| 78 | HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid);
|
---|
| 79 | HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid);
|
---|
| 80 | INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
|
---|
| 81 | PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags);
|
---|
| 82 | HRESULT WINAPI InitPropVariantFromFileTime(const FILETIME *pftIn, PROPVARIANT *ppropvar);
|
---|
| 83 |
|
---|
| 84 | HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret);
|
---|
| 85 | HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret);
|
---|
| 86 | HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret);
|
---|
| 87 | HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
|
---|
| 88 | HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret);
|
---|
| 89 | HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret);
|
---|
| 90 | HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret);
|
---|
| 91 | HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, WINBOOL *ret);
|
---|
| 92 | HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb);
|
---|
| 93 | HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch);
|
---|
| 94 | PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault);
|
---|
| 95 |
|
---|
| 96 | HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret);
|
---|
| 97 |
|
---|
| 98 | #ifdef __cplusplus
|
---|
| 99 |
|
---|
| 100 | HRESULT InitPropVariantFromBoolean(WINBOOL fVal, PROPVARIANT *ppropvar);
|
---|
| 101 | HRESULT InitPropVariantFromInt16(SHORT nVal, PROPVARIANT *ppropvar);
|
---|
| 102 | HRESULT InitPropVariantFromUInt16(USHORT uiVal, PROPVARIANT *ppropvar);
|
---|
| 103 | HRESULT InitPropVariantFromInt32(LONG lVal, PROPVARIANT *ppropvar);
|
---|
| 104 | HRESULT InitPropVariantFromUInt32(ULONG ulVal, PROPVARIANT *ppropvar);
|
---|
| 105 | HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar);
|
---|
| 106 | HRESULT InitPropVariantFromUInt64(ULONGLONG ullVal, PROPVARIANT *ppropvar);
|
---|
| 107 | HRESULT InitPropVariantFromDouble(DOUBLE dblVal, PROPVARIANT *ppropvar);
|
---|
| 108 | HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar);
|
---|
| 109 | HRESULT InitPropVariantFromGUIDAsBuffer(REFGUID guid, PROPVARIANT *ppropvar);
|
---|
| 110 | WINBOOL IsPropVariantVector(REFPROPVARIANT propvar);
|
---|
| 111 | WINBOOL IsPropVariantString(REFPROPVARIANT propvar);
|
---|
| 112 |
|
---|
| 113 | #ifndef NO_PROPVAR_INLINES
|
---|
| 114 |
|
---|
| 115 | inline HRESULT InitPropVariantFromBoolean(WINBOOL fVal, PROPVARIANT *ppropvar)
|
---|
| 116 | {
|
---|
| 117 | ppropvar->vt = VT_BOOL;
|
---|
| 118 | ppropvar->boolVal = fVal ? VARIANT_TRUE : VARIANT_FALSE;
|
---|
| 119 | return S_OK;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | inline HRESULT InitPropVariantFromInt16(SHORT nVal, PROPVARIANT *ppropvar)
|
---|
| 123 | {
|
---|
| 124 | ppropvar->vt = VT_I2;
|
---|
| 125 | ppropvar->iVal = nVal;
|
---|
| 126 | return S_OK;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | inline HRESULT InitPropVariantFromUInt16(USHORT uiVal, PROPVARIANT *ppropvar)
|
---|
| 130 | {
|
---|
| 131 | ppropvar->vt = VT_UI2;
|
---|
| 132 | ppropvar->uiVal = uiVal;
|
---|
| 133 | return S_OK;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | inline HRESULT InitPropVariantFromInt32(LONG lVal, PROPVARIANT *ppropvar)
|
---|
| 137 | {
|
---|
| 138 | ppropvar->vt = VT_I4;
|
---|
| 139 | ppropvar->lVal = lVal;
|
---|
| 140 | return S_OK;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | inline HRESULT InitPropVariantFromUInt32(ULONG ulVal, PROPVARIANT *ppropvar)
|
---|
| 144 | {
|
---|
| 145 | ppropvar->vt = VT_UI4;
|
---|
| 146 | ppropvar->ulVal = ulVal;
|
---|
| 147 | return S_OK;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | inline HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar)
|
---|
| 151 | {
|
---|
| 152 | ppropvar->vt = VT_I8;
|
---|
| 153 | ppropvar->hVal.QuadPart = llVal;
|
---|
| 154 | return S_OK;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | inline HRESULT InitPropVariantFromUInt64(ULONGLONG ullVal, PROPVARIANT *ppropvar)
|
---|
| 158 | {
|
---|
| 159 | ppropvar->vt = VT_UI8;
|
---|
| 160 | ppropvar->uhVal.QuadPart = ullVal;
|
---|
| 161 | return S_OK;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | inline HRESULT InitPropVariantFromDouble(DOUBLE dblVal, PROPVARIANT *ppropvar)
|
---|
| 165 | {
|
---|
| 166 | ppropvar->vt = VT_R8;
|
---|
| 167 | ppropvar->dblVal = dblVal;
|
---|
| 168 | return S_OK;
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | inline HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar)
|
---|
| 172 | {
|
---|
| 173 | HRESULT hres;
|
---|
| 174 |
|
---|
| 175 | hres = SHStrDupW(psz, &ppropvar->pwszVal);
|
---|
| 176 | if(SUCCEEDED(hres))
|
---|
| 177 | ppropvar->vt = VT_LPWSTR;
|
---|
| 178 | else
|
---|
| 179 | PropVariantInit(ppropvar);
|
---|
| 180 |
|
---|
| 181 | return hres;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | inline HRESULT InitPropVariantFromGUIDAsBuffer(REFGUID guid, PROPVARIANT *ppropvar)
|
---|
| 185 | {
|
---|
| 186 | #ifdef __cplusplus
|
---|
| 187 | return InitPropVariantFromBuffer(&guid, sizeof(GUID), ppropvar);
|
---|
| 188 | #else
|
---|
| 189 | return InitPropVariantFromBuffer(guid, sizeof(GUID), ppropvar);
|
---|
| 190 | #endif
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | inline WINBOOL IsPropVariantVector(REFPROPVARIANT propvar)
|
---|
| 194 | {
|
---|
| 195 | return (propvar.vt & (VT_ARRAY | VT_VECTOR));
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | inline WINBOOL IsPropVariantString(REFPROPVARIANT propvar)
|
---|
| 199 | {
|
---|
| 200 | return (PropVariantToStringWithDefault(propvar, NULL) != NULL);
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | #endif /* NO_PROPVAR_INLINES */
|
---|
| 204 | #endif /* __cplusplus */
|
---|
| 205 |
|
---|
| 206 |
|
---|
| 207 | #ifdef __cplusplus
|
---|
| 208 | }
|
---|
| 209 | #endif
|
---|
| 210 |
|
---|
| 211 | #endif /* __WINE_PROPVARUTIL_H */
|
---|