GeneralHelper.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /*
  2. * Copyright: JessMA Open Source (ldcsaa@gmail.com)
  3. *
  4. * Version : 2.3.15
  5. * Author : Bruce Liang
  6. * Website : http://www.jessma.org
  7. * Project : https://github.com/ldcsaa
  8. * Blog : http://www.cnblogs.com/ldcsaa
  9. * Wiki : http://www.oschina.net/p/hp-socket
  10. * QQ Group : 75375912
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the "License");
  13. * you may not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an "AS IS" BASIS,
  20. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. /*
  25. Optional Macros:
  26. Windows:
  27. ++++++++++++++++++++++
  28. _WIN32_WINNT : Windows NT 版本 (默认:_WIN32_WINNT_WINXP / _WIN32_WINNT_WIN7)
  29. WINVER : Windows 版本 (默认:_WIN32_WINNT)
  30. _USE_MFC : 使用 MFC
  31. _WINSOCK_SUPPORT : 支持 Windows Socket
  32. _NO_RIBBONS_SUPPORT : 不支持 Ribbons 界面风格
  33. _DETECT_MEMORY_LEAK : DEBUG 状态下支持内存泄露检查
  34. Windows CE:
  35. ++++++++++++++++++++++
  36. WINVER : Windows 版本
  37. _USE_MFC : 使用 MFC
  38. _WINSOCK_SUPPORT : 支持 Windows Socket
  39. _DETECT_MEMORY_LEAK : DEBUG 状态下支持内存泄露检查
  40. _ONLY_DETECT_CONFIRMED_MEMORY_LEAK_ : 只报告能够确认的内存泄露(不能确定的不报告)
  41. ---------------------------
  42. VC 2015
  43. _MSC_VER == 1900
  44. VC 2013
  45. _MSC_VER == 1800
  46. VC 2012
  47. _MSC_VER == 1700
  48. VC 2010
  49. _MSC_VER == 1600
  50. VC 2008
  51. _MSC_VER == 1500
  52. VC 2005
  53. _MSC_VER == 1400
  54. VC 7.1
  55. _MSC_VER == 1310
  56. VC 7.0
  57. _MSC_VER == 1300
  58. VC 6.0
  59. _MSC_VER == 1200
  60. ---------------------------
  61. Windows Versions:
  62. _WIN32_WINNT_NT4 x0400
  63. _WIN32_WINNT_WIN2K 0x0500
  64. _WIN32_WINNT_WINXP 0x0501
  65. _WIN32_WINNT_WS03 0x0502
  66. _WIN32_WINNT_WIN6 0x0600
  67. _WIN32_WINNT_VISTA 0x0600
  68. _WIN32_WINNT_WS08 0x0600
  69. _WIN32_WINNT_LONGHORN 0x0600
  70. _WIN32_WINNT_WIN7 0x0601
  71. _WIN32_WINNT_WIN8 0x0602
  72. _WIN32_WINNT_WINBLUE 0x0603
  73. _WIN32_WINNT_WIN10 0x0A00
  74. ---------------------------
  75. */
  76. #pragma once
  77. #ifndef VC_EXTRALEAN
  78. #define VC_EXTRALEAN
  79. #endif
  80. #ifndef WIN32_LEAN_AND_MEAN
  81. #define WIN32_LEAN_AND_MEAN
  82. #endif
  83. #ifndef _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
  84. #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
  85. #endif
  86. #if _MSC_VER >= 1400
  87. #if defined _DEBUG && _MSC_VER < 1600
  88. #ifndef _SECURE_SCL
  89. #define _SECURE_SCL 0
  90. #endif
  91. #ifndef _HAS_ITERATOR_DEBUGGING
  92. #define _HAS_ITERATOR_DEBUGGING 0
  93. #endif
  94. #endif
  95. #ifndef _CRT_SECURE_NO_DEPRECATE
  96. #define _CRT_SECURE_NO_DEPRECATE 1
  97. #endif
  98. #ifndef _SCL_SECURE_NO_DEPRECATE
  99. #define _SCL_SECURE_NO_DEPRECATE 1
  100. #endif
  101. #ifndef _ATL_SECURE_NO_WARNINGS
  102. #define _ATL_SECURE_NO_WARNINGS 1
  103. #endif
  104. #ifndef _CRT_NON_CONFORMING_SWPRINTFS
  105. #define _CRT_NON_CONFORMING_SWPRINTFS 1
  106. #endif
  107. #ifndef _SECURE_ATL
  108. #define _SECURE_ATL 1
  109. #endif
  110. #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
  111. #define _WINSOCK_DEPRECATED_NO_WARNINGS 1
  112. #endif
  113. #endif
  114. #ifndef _WIN32_WINNT
  115. #if defined (_WIN64)
  116. #define _WIN32_WINNT _WIN32_WINNT_WIN7
  117. #else
  118. #define _WIN32_WINNT _WIN32_WINNT_WINXP
  119. #endif
  120. #endif
  121. #ifndef WINVER
  122. #define WINVER _WIN32_WINNT
  123. #endif
  124. #if _MSC_VER >= 1600
  125. #include <SDKDDKVer.h>
  126. #else
  127. #if !defined(nullptr)
  128. #define nullptr NULL
  129. #endif
  130. #endif
  131. #ifdef _DETECT_MEMORY_LEAK
  132. #ifndef _CRTDBG_MAP_ALLOC
  133. #define _CRTDBG_MAP_ALLOC
  134. #endif
  135. #endif
  136. #ifdef _USE_MFC
  137. #ifndef _AFX_ALL_WARNINGS
  138. #define _AFX_ALL_WARNINGS
  139. #endif
  140. #include <afxwin.h>
  141. #include <afxext.h>
  142. #include <afxdisp.h>
  143. #ifndef _AFX_NO_OLE_SUPPORT
  144. #include <afxdtctl.h>
  145. #endif
  146. #ifndef _AFX_NO_AFXCMN_SUPPORT
  147. #include <afxcmn.h>
  148. #endif
  149. #ifndef _NO_RIBBONS_SUPPORT
  150. #include <afxcontrolbars.h>
  151. #endif
  152. #else
  153. #include <Windows.h>
  154. #include <WindowsX.h>
  155. #include <commctrl.h>
  156. #include <stdio.h>
  157. #include <stdlib.h>
  158. #include <malloc.h>
  159. #include <memory.h>
  160. #include <tchar.h>
  161. #include <atlstr.h>
  162. #include <atltime.h>
  163. #ifndef ASSERT
  164. #define ASSERT(f) ATLASSERT(f)
  165. #endif
  166. #ifndef VERIFY
  167. #define VERIFY(f) ATLVERIFY(f)
  168. #endif
  169. #ifndef TRACE
  170. #include <atltrace.h>
  171. #define TRACE AtlTrace
  172. #define TRACE0(f) TRACE(f)
  173. #define TRACE1(f, p1) TRACE(f, p1)
  174. #define TRACE2(f, p1, p2) TRACE(f, p1, p2)
  175. #define TRACE3(f, p1, p2, p3) TRACE(f, p1, p2, p3)
  176. #define TRACE4(f, p1, p2, p3, p4) TRACE(f, p1, p2, p3, p4)
  177. #define TRACE5(f, p1, p2, p3, p4, p5) TRACE(f, p1, p2, p3, p4, p5)
  178. #endif
  179. #endif
  180. #ifdef _WINSOCK_SUPPORT
  181. #include <winsock2.h>
  182. #include <ws2tcpip.h>
  183. #include <mswsock.h>
  184. #endif
  185. #include <atlbase.h>
  186. #include <atlconv.h>
  187. #include "Singleton.h"
  188. #include "Event.h"
  189. #include "Semaphore.h"
  190. #include "CriticalSection.h"
  191. #include "STLHelper.h"
  192. #include "Win32Helper.h"
  193. #include "PrivateHeap.h"
  194. #include "bufferptr.h"
  195. #if defined (_DEBUG) && defined (_DETECT_MEMORY_LEAK)
  196. #include "debug/win32_crtdbg.h"
  197. #endif