1 // Windows/PropVariantConv.h
2
3 #ifndef __PROP_VARIANT_CONV_H
4 #define __PROP_VARIANT_CONV_H
5
6 #include "../Common/MyTypes.h"
7
8 // provide at least 32 bytes for buffer including zero-end
9
10 #define kTimestampPrintLevel_DAY -3
11 // #define kTimestampPrintLevel_HOUR -2
12 #define kTimestampPrintLevel_MIN -1
13 #define kTimestampPrintLevel_SEC 0
14 #define kTimestampPrintLevel_NTFS 7
15 #define kTimestampPrintLevel_NS 9
16
17 bool ConvertUtcFileTimeToString(const FILETIME &ft, char *s, int level = kTimestampPrintLevel_SEC) throw();
18 bool ConvertUtcFileTimeToString(const FILETIME &ft, wchar_t *s, int level = kTimestampPrintLevel_SEC) throw();
19 bool ConvertUtcFileTimeToString2(const FILETIME &ft, unsigned ns100, char *s, int level = kTimestampPrintLevel_SEC) throw();
20 bool ConvertUtcFileTimeToString2(const FILETIME &ft, unsigned ns100, wchar_t *s, int level = kTimestampPrintLevel_SEC) throw();
21
22 // provide at least 32 bytes for buffer including zero-end
23 // don't send VT_BSTR to these functions
24 void ConvertPropVariantToShortString(const PROPVARIANT &prop, char *dest) throw();
25 void ConvertPropVariantToShortString(const PROPVARIANT &prop, wchar_t *dest) throw();
26
ConvertPropVariantToUInt64(const PROPVARIANT & prop,UInt64 & value)27 inline bool ConvertPropVariantToUInt64(const PROPVARIANT &prop, UInt64 &value)
28 {
29 switch (prop.vt)
30 {
31 case VT_UI8: value = (UInt64)prop.uhVal.QuadPart; return true;
32 case VT_UI4: value = prop.ulVal; return true;
33 case VT_UI2: value = prop.uiVal; return true;
34 case VT_UI1: value = prop.bVal; return true;
35 case VT_EMPTY: return false;
36 default: throw 151199;
37 }
38 }
39
40 #endif
41