UnWindows.h 4.2 KB

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