1 // MyWindows.h 2 3 #ifndef __MY_WINDOWS_H 4 #define __MY_WINDOWS_H 5 6 #ifdef _WIN32 7 8 #include <windows.h> 9 10 #ifdef UNDER_CE 11 #undef VARIANT_TRUE 12 #define VARIANT_TRUE ((VARIANT_BOOL)-1) 13 #endif 14 15 #else 16 17 #include <stddef.h> // for wchar_t 18 #include <string.h> 19 // #include <stdint.h> // for uintptr_t 20 21 #include "MyGuidDef.h" 22 23 #define WINAPI 24 25 typedef char CHAR; 26 typedef unsigned char UCHAR; 27 28 #undef BYTE 29 typedef unsigned char BYTE; 30 31 typedef short SHORT; 32 typedef unsigned short USHORT; 33 34 #undef WORD 35 typedef unsigned short WORD; 36 typedef short VARIANT_BOOL; 37 38 typedef int INT; 39 typedef Int32 INT32; 40 typedef unsigned int UINT; 41 typedef UInt32 UINT32; 42 typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit 43 typedef UINT32 ULONG; 44 45 #undef DWORD 46 typedef UINT32 DWORD; 47 48 typedef long BOOL; 49 50 #ifndef FALSE 51 #define FALSE 0 52 #define TRUE 1 53 #endif 54 55 // typedef size_t ULONG_PTR; 56 typedef size_t DWORD_PTR; 57 // typedef uintptr_t UINT_PTR; 58 // typedef ptrdiff_t UINT_PTR; 59 60 typedef Int64 LONGLONG; 61 typedef UInt64 ULONGLONG; 62 63 typedef struct _LARGE_INTEGER { LONGLONG QuadPart; } LARGE_INTEGER; 64 typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart; } ULARGE_INTEGER; 65 66 typedef const CHAR *LPCSTR; 67 typedef CHAR TCHAR; 68 typedef const TCHAR *LPCTSTR; 69 typedef wchar_t WCHAR; 70 typedef WCHAR OLECHAR; 71 typedef const WCHAR *LPCWSTR; 72 typedef OLECHAR *BSTR; 73 typedef const OLECHAR *LPCOLESTR; 74 typedef OLECHAR *LPOLESTR; 75 76 typedef struct _FILETIME 77 { 78 DWORD dwLowDateTime; 79 DWORD dwHighDateTime; 80 } FILETIME; 81 82 #define HRESULT LONG 83 #define FAILED(Status) ((HRESULT)(Status)<0) 84 typedef ULONG PROPID; 85 typedef LONG SCODE; 86 87 #define ERROR_NEGATIVE_SEEK 131L 88 89 #define S_OK ((HRESULT)0x00000000L) 90 #define S_FALSE ((HRESULT)0x00000001L) 91 #define E_NOTIMPL ((HRESULT)0x80004001L) 92 #define E_NOINTERFACE ((HRESULT)0x80004002L) 93 #define E_ABORT ((HRESULT)0x80004004L) 94 #define E_FAIL ((HRESULT)0x80004005L) 95 #define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L) 96 #define E_OUTOFMEMORY ((HRESULT)0x8007000EL) 97 #define E_INVALIDARG ((HRESULT)0x80070057L) 98 99 #ifdef _MSC_VER 100 #define STDMETHODCALLTYPE __stdcall 101 #else 102 #define STDMETHODCALLTYPE 103 #endif 104 105 #define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f 106 #define STDMETHOD(f) STDMETHOD_(HRESULT, f) 107 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE 108 #define STDMETHODIMP STDMETHODIMP_(HRESULT) 109 110 #define PURE = 0 111 112 #define MIDL_INTERFACE(x) struct 113 114 #ifdef __cplusplus 115 116 DEFINE_GUID(IID_IUnknown, 117 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); 118 struct IUnknown 119 { 120 STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE; 121 STDMETHOD_(ULONG, AddRef)() PURE; 122 STDMETHOD_(ULONG, Release)() PURE; 123 #ifndef _WIN32 ~IUnknownIUnknown124 virtual ~IUnknown() {} 125 #endif 126 }; 127 128 typedef IUnknown *LPUNKNOWN; 129 130 #endif 131 132 #define VARIANT_TRUE ((VARIANT_BOOL)-1) 133 #define VARIANT_FALSE ((VARIANT_BOOL)0) 134 135 enum VARENUM 136 { 137 VT_EMPTY = 0, 138 VT_NULL = 1, 139 VT_I2 = 2, 140 VT_I4 = 3, 141 VT_R4 = 4, 142 VT_R8 = 5, 143 VT_CY = 6, 144 VT_DATE = 7, 145 VT_BSTR = 8, 146 VT_DISPATCH = 9, 147 VT_ERROR = 10, 148 VT_BOOL = 11, 149 VT_VARIANT = 12, 150 VT_UNKNOWN = 13, 151 VT_DECIMAL = 14, 152 VT_I1 = 16, 153 VT_UI1 = 17, 154 VT_UI2 = 18, 155 VT_UI4 = 19, 156 VT_I8 = 20, 157 VT_UI8 = 21, 158 VT_INT = 22, 159 VT_UINT = 23, 160 VT_VOID = 24, 161 VT_HRESULT = 25, 162 VT_FILETIME = 64 163 }; 164 165 typedef unsigned short VARTYPE; 166 typedef WORD PROPVAR_PAD1; 167 typedef WORD PROPVAR_PAD2; 168 typedef WORD PROPVAR_PAD3; 169 170 typedef struct tagPROPVARIANT 171 { 172 VARTYPE vt; 173 PROPVAR_PAD1 wReserved1; 174 PROPVAR_PAD2 wReserved2; 175 PROPVAR_PAD3 wReserved3; 176 union 177 { 178 CHAR cVal; 179 UCHAR bVal; 180 SHORT iVal; 181 USHORT uiVal; 182 LONG lVal; 183 ULONG ulVal; 184 INT intVal; 185 UINT uintVal; 186 LARGE_INTEGER hVal; 187 ULARGE_INTEGER uhVal; 188 VARIANT_BOOL boolVal; 189 SCODE scode; 190 FILETIME filetime; 191 BSTR bstrVal; 192 }; 193 } PROPVARIANT; 194 195 typedef PROPVARIANT tagVARIANT; 196 typedef tagVARIANT VARIANT; 197 typedef VARIANT VARIANTARG; 198 199 MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop); 200 MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, const VARIANTARG *src); 201 202 typedef struct tagSTATPROPSTG 203 { 204 LPOLESTR lpwstrName; 205 PROPID propid; 206 VARTYPE vt; 207 } STATPROPSTG; 208 209 MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len); 210 MY_EXTERN_C BSTR SysAllocStringLen(const OLECHAR *sz, UINT len); 211 MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz); 212 MY_EXTERN_C void SysFreeString(BSTR bstr); 213 MY_EXTERN_C UINT SysStringByteLen(BSTR bstr); 214 MY_EXTERN_C UINT SysStringLen(BSTR bstr); 215 216 MY_EXTERN_C DWORD GetLastError(); 217 MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2); 218 219 #define CP_ACP 0 220 #define CP_OEMCP 1 221 #define CP_UTF8 65001 222 223 typedef enum tagSTREAM_SEEK 224 { 225 STREAM_SEEK_SET = 0, 226 STREAM_SEEK_CUR = 1, 227 STREAM_SEEK_END = 2 228 } STREAM_SEEK; 229 230 #endif 231 #endif 232