UnWindows.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // UnWindows.h
  3. //
  4. // $Id: //poco/1.4/Foundation/include/Poco/UnWindows.h#1 $
  5. //
  6. // Library: Foundation
  7. // Package: Core
  8. // Module: UnWindows
  9. //
  10. // A wrapper around the <windows.h> header file that #undef's some
  11. // of the macros for function names defined by <windows.h> that
  12. // are a frequent source of conflicts (e.g., GetUserName).
  13. //
  14. // Remember, that most of the WIN32 API functions come in two variants,
  15. // an Unicode variant (e.g., GetUserNameA) and an ASCII variant (GetUserNameW).
  16. // There is also a macro (GetUserName) that's either defined to be the Unicode
  17. // name or the ASCII name, depending on whether the UNICODE macro is #define'd
  18. // or not. POCO always calls the Unicode or ASCII functions directly (depending
  19. // on whether POCO_WIN32_UTF8 is #define'd or not), so the macros are not ignored.
  20. //
  21. // These macro definitions are a frequent case of problems and naming conflicts,
  22. // especially for C++ programmers. Say, you define a class with a member function named
  23. // GetUserName. Depending on whether "Poco/UnWindows.h" has been included by a particular
  24. // translation unit or not, this might be changed to GetUserNameA/GetUserNameW, or not.
  25. // While, due to naming conventions used, this is less of a problem in POCO, some
  26. // of the users of POCO might use a different naming convention where this can become
  27. // a problem.
  28. //
  29. // To disable the #undef's, compile POCO with the POCO_NO_UNWINDOWS macro #define'd.
  30. //
  31. // Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
  32. // and Contributors.
  33. //
  34. // SPDX-License-Identifier: BSL-1.0
  35. //
  36. #ifndef Foundation_UnWindows_INCLUDED
  37. #define Foundation_UnWindows_INCLUDED
  38. // Reduce bloat
  39. #if defined(_WIN32)
  40. #if !defined(WIN32_LEAN_AND_MEAN) && !defined(POCO_BLOATED_WIN32)
  41. #define WIN32_LEAN_AND_MEAN
  42. #endif
  43. #endif
  44. // Microsoft Visual C++ includes copies of the Windows header files
  45. // that were current at the time Visual C++ was released.
  46. // The Windows header files use macros to indicate which versions
  47. // of Windows support many programming elements. Therefore, you must
  48. // define these macros to use new functionality introduced in each
  49. // major operating system release. (Individual header files may use
  50. // different macros; therefore, if compilation problems occur, check
  51. // the header file that contains the definition for conditional
  52. // definitions.) For more information, see SdkDdkVer.h.
  53. #if !defined(_WIN32_WCE)
  54. #if defined(_WIN32_WINNT)
  55. #if (_WIN32_WINNT < 0x0501)
  56. #error Unsupported Windows version.
  57. #endif
  58. #elif defined(NTDDI_VERSION)
  59. #if (NTDDI_VERSION < 0x05010100)
  60. #error Unsupported Windows version.
  61. #endif
  62. #elif !defined(_WIN32_WINNT)
  63. // Define minimum supported version.
  64. // This can be changed, if needed.
  65. // If allowed (see POCO_MIN_WINDOWS_OS_SUPPORT
  66. // below), Platform_WIN32.h will do its
  67. // best to determine the appropriate values
  68. // and may redefine these. See Platform_WIN32.h
  69. // for details.
  70. #define _WIN32_WINNT 0x0501
  71. #define NTDDI_VERSION 0x05010100
  72. #endif
  73. #endif
  74. // To prevent Platform_WIN32.h to modify version defines,
  75. // uncomment this, otherwise versions will be automatically
  76. // discovered in Platform_WIN32.h.
  77. // #define POCO_FORCE_MIN_WINDOWS_OS_SUPPORT
  78. #include <windows.h>
  79. #if !defined(POCO_NO_UNWINDOWS)
  80. // A list of annoying macros to #undef.
  81. // Extend as required.
  82. #undef GetBinaryType
  83. #undef GetShortPathName
  84. #undef GetLongPathName
  85. #undef GetEnvironmentStrings
  86. #undef SetEnvironmentStrings
  87. #undef FreeEnvironmentStrings
  88. #undef FormatMessage
  89. #undef EncryptFile
  90. #undef DecryptFile
  91. #undef CreateMutex
  92. #undef OpenMutex
  93. #undef CreateEvent
  94. #undef OpenEvent
  95. #undef CreateSemaphore
  96. #undef OpenSemaphore
  97. #undef LoadLibrary
  98. #undef GetModuleFileName
  99. #undef CreateProcess
  100. #undef GetCommandLine
  101. #undef GetEnvironmentVariable
  102. #undef SetEnvironmentVariable
  103. #undef ExpandEnvironmentStrings
  104. #undef OutputDebugString
  105. #undef FindResource
  106. #undef UpdateResource
  107. #undef FindAtom
  108. #undef AddAtom
  109. #undef GetSystemDirectory
  110. #undef GetTempPath
  111. #undef GetTempFileName
  112. #undef SetCurrentDirectory
  113. #undef GetCurrentDirectory
  114. #undef CreateDirectory
  115. #undef RemoveDirectory
  116. #undef CreateFile
  117. #undef DeleteFile
  118. #undef SearchPath
  119. #undef CopyFile
  120. #undef MoveFile
  121. #undef ReplaceFile
  122. #undef GetComputerName
  123. #undef SetComputerName
  124. #undef GetUserName
  125. #undef LogonUser
  126. #undef GetVersion
  127. #undef GetObject
  128. #endif // POCO_NO_UNWINDOWS
  129. #endif // Foundation_UnWindows_INCLUDED