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