aboutsummaryrefslogtreecommitdiff
path: root/CPP/Common/MyWindows.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/Common/MyWindows.h120
1 files changed, 88 insertions, 32 deletions
diff --git a/CPP/Common/MyWindows.h b/CPP/Common/MyWindows.h
index 15db524..a76e14b 100644
--- a/CPP/Common/MyWindows.h
+++ b/CPP/Common/MyWindows.h
@@ -1,16 +1,25 @@
1// MyWindows.h 1// MyWindows.h
2 2
3#ifndef __MY_WINDOWS_H 3#ifdef Z7_DEFINE_GUID
4#define __MY_WINDOWS_H 4#undef Z7_DEFINE_GUID
5#endif
5 6
6#ifdef _WIN32 7#ifdef INITGUID
8 #define Z7_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
9 EXTERN_C const GUID name; \
10 EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
11#else
12 #define Z7_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
13 EXTERN_C const GUID name
14#endif
7 15
8#include <Windows.h>
9 16
10#ifdef UNDER_CE 17#ifndef ZIP7_INC_MY_WINDOWS_H
11 #undef VARIANT_TRUE 18#define ZIP7_INC_MY_WINDOWS_H
12 #define VARIANT_TRUE ((VARIANT_BOOL)-1) 19
13#endif 20#ifdef _WIN32
21
22#include "../../C/7zWindows.h"
14 23
15#else // _WIN32 24#else // _WIN32
16 25
@@ -18,11 +27,11 @@
18#include <string.h> 27#include <string.h>
19// #include <stdint.h> // for uintptr_t 28// #include <stdint.h> // for uintptr_t
20 29
30#include "../../C/7zTypes.h"
21#include "MyGuidDef.h" 31#include "MyGuidDef.h"
22 32
23// WINAPI is __stdcall in Windows-MSVC in windef.h 33// WINAPI is __stdcall in Windows-MSVC in windef.h
24#define WINAPI 34#define WINAPI
25#define EXTERN_C MY_EXTERN_C
26 35
27typedef char CHAR; 36typedef char CHAR;
28typedef unsigned char UCHAR; 37typedef unsigned char UCHAR;
@@ -103,31 +112,78 @@ typedef LONG SCODE;
103 112
104#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE 113#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
105 114
106#define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f 115#ifndef DECLSPEC_NOTHROW
107#define STDMETHOD(f) STDMETHOD_(HRESULT, f) 116#define DECLSPEC_NOTHROW Z7_DECLSPEC_NOTHROW
108#define STDMETHODIMP_(type) type STDMETHODCALLTYPE 117#endif
109#define STDMETHODIMP STDMETHODIMP_(HRESULT) 118
119#ifndef DECLSPEC_NOVTABLE
120#define DECLSPEC_NOVTABLE Z7_DECLSPEC_NOVTABLE
121#endif
122
123#ifndef COM_DECLSPEC_NOTHROW
124#ifdef COM_STDMETHOD_CAN_THROW
125 #define COM_DECLSPEC_NOTHROW
126#else
127 #define COM_DECLSPEC_NOTHROW DECLSPEC_NOTHROW
128#endif
129#endif
130
131#define DECLARE_INTERFACE(iface) struct DECLSPEC_NOVTABLE iface
132#define DECLARE_INTERFACE_(iface, baseiface) struct DECLSPEC_NOVTABLE iface : public baseiface
133
134#define STDMETHOD_(t, f) virtual COM_DECLSPEC_NOTHROW t STDMETHODCALLTYPE f
135#define STDMETHOD(f) STDMETHOD_(HRESULT, f)
136#define STDMETHODIMP_(t) COM_DECLSPEC_NOTHROW t STDMETHODCALLTYPE
137#define STDMETHODIMP STDMETHODIMP_(HRESULT)
138
110 139
111#define PURE = 0 140#define PURE = 0
112 141
113#define MIDL_INTERFACE(x) struct 142// #define MIDL_INTERFACE(x) struct
143
114 144
115#ifdef __cplusplus 145#ifdef __cplusplus
116 146
147/*
148 p7zip and 7-Zip before v23 used virtual destructor in IUnknown,
149 if _WIN32 is not defined.
150 It used virtual destructor, because some compilers don't like virtual
151 interfaces without virtual destructor.
152 IUnknown in Windows (_WIN32) doesn't use virtual destructor in IUnknown.
153 We still can define Z7_USE_VIRTUAL_DESTRUCTOR_IN_IUNKNOWN here,
154 if we want to be compatible with old plugin interface of p7zip and 7-Zip before v23.
155
156v23:
157 In new 7-Zip v23 we try to be more compatible with original IUnknown from _WIN32.
158 So we do not define Z7_USE_VIRTUAL_DESTRUCTOR_IN_IUNKNOWN here,
159*/
160// #define Z7_USE_VIRTUAL_DESTRUCTOR_IN_IUNKNOWN
161
162#ifdef Z7_USE_VIRTUAL_DESTRUCTOR_IN_IUNKNOWN
163#if defined(__clang__)
164#pragma GCC diagnostic ignored "-Winconsistent-missing-destructor-override"
165#endif
166#endif
167
168Z7_PURE_INTERFACES_BEGIN
169
117DEFINE_GUID(IID_IUnknown, 170DEFINE_GUID(IID_IUnknown,
1180x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); 1710x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
119struct IUnknown 172struct IUnknown
120{ 173{
121 STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE; 174 STDMETHOD(QueryInterface) (REFIID iid, void **outObject) =0;
122 STDMETHOD_(ULONG, AddRef)() PURE; 175 STDMETHOD_(ULONG, AddRef)() =0;
123 STDMETHOD_(ULONG, Release)() PURE; 176 STDMETHOD_(ULONG, Release)() =0;
177 #ifdef Z7_USE_VIRTUAL_DESTRUCTOR_IN_IUNKNOWN
124 virtual ~IUnknown() {} 178 virtual ~IUnknown() {}
125 // We use virtual ~IUnknown() here for binary compatibility with 7z.so from p7zip 179 #endif
126}; 180};
127 181
128typedef IUnknown *LPUNKNOWN; 182typedef IUnknown *LPUNKNOWN;
129 183
130#endif 184Z7_PURE_INTERFACES_END
185
186#endif // __cplusplus
131 187
132#define VARIANT_TRUE ((VARIANT_BOOL)-1) 188#define VARIANT_TRUE ((VARIANT_BOOL)-1)
133#define VARIANT_FALSE ((VARIANT_BOOL)0) 189#define VARIANT_FALSE ((VARIANT_BOOL)0)
@@ -197,8 +253,8 @@ typedef PROPVARIANT tagVARIANT;
197typedef tagVARIANT VARIANT; 253typedef tagVARIANT VARIANT;
198typedef VARIANT VARIANTARG; 254typedef VARIANT VARIANTARG;
199 255
200MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop); 256EXTERN_C HRESULT VariantClear(VARIANTARG *prop);
201MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, const VARIANTARG *src); 257EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, const VARIANTARG *src);
202 258
203typedef struct tagSTATPROPSTG 259typedef struct tagSTATPROPSTG
204{ 260{
@@ -207,19 +263,19 @@ typedef struct tagSTATPROPSTG
207 VARTYPE vt; 263 VARTYPE vt;
208} STATPROPSTG; 264} STATPROPSTG;
209 265
210MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len); 266EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);
211MY_EXTERN_C BSTR SysAllocStringLen(const OLECHAR *sz, UINT len); 267EXTERN_C BSTR SysAllocStringLen(const OLECHAR *sz, UINT len);
212MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz); 268EXTERN_C BSTR SysAllocString(const OLECHAR *sz);
213MY_EXTERN_C void SysFreeString(BSTR bstr); 269EXTERN_C void SysFreeString(BSTR bstr);
214MY_EXTERN_C UINT SysStringByteLen(BSTR bstr); 270EXTERN_C UINT SysStringByteLen(BSTR bstr);
215MY_EXTERN_C UINT SysStringLen(BSTR bstr); 271EXTERN_C UINT SysStringLen(BSTR bstr);
216 272
217MY_EXTERN_C DWORD GetLastError(); 273EXTERN_C DWORD GetLastError();
218MY_EXTERN_C void SetLastError(DWORD dwCode); 274EXTERN_C void SetLastError(DWORD dwCode);
219MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2); 275EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
220 276
221MY_EXTERN_C DWORD GetCurrentThreadId(); 277EXTERN_C DWORD GetCurrentThreadId();
222MY_EXTERN_C DWORD GetCurrentProcessId(); 278EXTERN_C DWORD GetCurrentProcessId();
223 279
224#define MAX_PATH 1024 280#define MAX_PATH 1024
225 281