xref: /reactos/sdk/include/psdk/propvarutil.h (revision 5bfe6a53)
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 enum tagPROPVAR_CHANGE_FLAGS
26 {
27     PVCHF_DEFAULT           = 0x00000000,
28     PVCHF_NOVALUEPROP       = 0x00000001,
29     PVCHF_ALPHABOOL         = 0x00000002,
30     PVCHF_NOUSEROVERRIDE    = 0x00000004,
31     PVCHF_LOCALBOOL         = 0x00000008,
32     PVCHF_NOHEXSTRING       = 0x00000010,
33 };
34 
35 typedef int PROPVAR_CHANGE_FLAGS;
36 
37 enum tagPROPVAR_COMPARE_UNIT
38 {
39     PVCU_DEFAULT           = 0x00000000,
40     PVCU_SECOND            = 0x00000001,
41     PVCU_MINUTE            = 0x00000002,
42     PVCU_HOUR              = 0x00000003,
43     PVCU_DAY               = 0x00000004,
44     PVCU_MONTH             = 0x00000005,
45     PVCU_YEAR              = 0x00000006,
46 };
47 
48 typedef int PROPVAR_COMPARE_UNIT;
49 
50 enum tagPROPVAR_COMPARE_FLAGS
51 {
52     PVCF_DEFAULT           = 0x00000000,
53     PVCF_TREATEMPTYASGREATERTHAN = 0x00000001,
54     PVCF_USESTRCMP         = 0x00000002,
55     PVCF_USESTRCMPC        = 0x00000004,
56     PVCF_USESTRCMPI        = 0x00000008,
57     PVCF_USESTRCMPIC       = 0x00000010,
58 };
59 
60 typedef int PROPVAR_COMPARE_FLAGS;
61 
62 HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
63                                      PROPVAR_CHANGE_FLAGS flags, VARTYPE vt);
64 HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar);
65 HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar);
66 HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar);
67 HRESULT WINAPI InitPropVariantFromCLSID(REFCLSID clsid, PROPVARIANT *ppropvar);
68 HRESULT WINAPI InitVariantFromBuffer(const VOID *pv, UINT cb, VARIANT *pvar);
69 HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid);
70 HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid);
71 INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
72                                 PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags);
73 
74 HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret);
75 HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret);
76 HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
77 HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret);
78 HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret);
79 HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret);
80 HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret);
81 PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault);
82 
83 HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret);
84 
85 #ifdef __cplusplus
86 
87 HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar);
88 HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar);
89 HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar);
90 
91 #ifndef NO_PROPVAR_INLINES
92 
93 inline HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar)
94 {
95     ppropvar->vt = VT_BOOL;
96     ppropvar->boolVal = fVal ? VARIANT_TRUE : VARIANT_FALSE;
97     return S_OK;
98 }
99 
100 inline HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar)
101 {
102     HRESULT hres;
103 
104     hres = SHStrDupW(psz, &ppropvar->pwszVal);
105     if(SUCCEEDED(hres))
106         ppropvar->vt = VT_LPWSTR;
107     else
108         PropVariantInit(ppropvar);
109 
110     return hres;
111 }
112 
113 inline HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar)
114 {
115     ppropvar->vt = VT_I8;
116     ppropvar->hVal.QuadPart = llVal;
117     return S_OK;
118 }
119 
120 #endif
121 #endif
122 
123 #endif /* __WINE_PROPVARUTIL_H */
124