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