handles.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2010 Vicente J. Botet Escriba
  3. * Copyright 2015 Andrey Semashev
  4. *
  5. * Distributed under the Boost Software License, Version 1.0.
  6. * See http://www.boost.org/LICENSE_1_0.txt
  7. */
  8. #ifndef BOOST_WINAPI_HANDLES_HPP_INCLUDED_
  9. #define BOOST_WINAPI_HANDLES_HPP_INCLUDED_
  10. #include <boost/winapi/basic_types.hpp>
  11. #ifdef BOOST_HAS_PRAGMA_ONCE
  12. #pragma once
  13. #endif
  14. #if !defined( BOOST_USE_WINDOWS_H )
  15. extern "C" {
  16. BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  17. CloseHandle(boost::winapi::HANDLE_ handle);
  18. BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  19. DuplicateHandle(
  20. boost::winapi::HANDLE_ hSourceProcessHandle,
  21. boost::winapi::HANDLE_ hSourceHandle,
  22. boost::winapi::HANDLE_ hTargetProcessHandle,
  23. boost::winapi::HANDLE_* lpTargetHandle,
  24. boost::winapi::DWORD_ dwDesiredAccess,
  25. boost::winapi::BOOL_ bInheritHandle,
  26. boost::winapi::DWORD_ dwOptions);
  27. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN10
  28. BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  29. CompareObjectHandles(
  30. boost::winapi::HANDLE_ hFirstObjectHandle,
  31. boost::winapi::HANDLE_ hSecondObjectHandle);
  32. #endif
  33. } // extern "C"
  34. #endif
  35. namespace boost {
  36. namespace winapi {
  37. using ::CloseHandle;
  38. using ::DuplicateHandle;
  39. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN10
  40. using ::CompareObjectHandles;
  41. #endif
  42. // Note: MSVC-14.1 does not interpret INVALID_HANDLE_VALUE_ initializer as a constant expression
  43. #if defined( BOOST_USE_WINDOWS_H )
  44. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_CLOSE_SOURCE_ = DUPLICATE_CLOSE_SOURCE;
  45. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_SAME_ACCESS_ = DUPLICATE_SAME_ACCESS;
  46. const HANDLE_ INVALID_HANDLE_VALUE_ = INVALID_HANDLE_VALUE;
  47. #else
  48. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_CLOSE_SOURCE_ = 1;
  49. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_SAME_ACCESS_ = 2;
  50. const HANDLE_ INVALID_HANDLE_VALUE_ = (HANDLE_)(-1);
  51. #endif
  52. BOOST_CONSTEXPR_OR_CONST DWORD_ duplicate_close_source = DUPLICATE_CLOSE_SOURCE_;
  53. BOOST_CONSTEXPR_OR_CONST DWORD_ duplicate_same_access = DUPLICATE_SAME_ACCESS_;
  54. // Note: The "unused" attribute here should not be necessary because the variable is a constant.
  55. // However, MinGW gcc 5.3 spams warnings about this particular constant.
  56. const HANDLE_ invalid_handle_value BOOST_ATTRIBUTE_UNUSED = INVALID_HANDLE_VALUE_;
  57. }
  58. }
  59. #endif // BOOST_WINAPI_HANDLES_HPP_INCLUDED_