handles.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <boost/winapi/detail/header.hpp>
  12. #ifdef BOOST_HAS_PRAGMA_ONCE
  13. #pragma once
  14. #endif
  15. #if !defined( BOOST_USE_WINDOWS_H )
  16. extern "C" {
  17. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  18. CloseHandle(boost::winapi::HANDLE_ handle);
  19. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  20. DuplicateHandle(
  21. boost::winapi::HANDLE_ hSourceProcessHandle,
  22. boost::winapi::HANDLE_ hSourceHandle,
  23. boost::winapi::HANDLE_ hTargetProcessHandle,
  24. boost::winapi::HANDLE_* lpTargetHandle,
  25. boost::winapi::DWORD_ dwDesiredAccess,
  26. boost::winapi::BOOL_ bInheritHandle,
  27. boost::winapi::DWORD_ dwOptions);
  28. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN10
  29. BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  30. CompareObjectHandles(
  31. boost::winapi::HANDLE_ hFirstObjectHandle,
  32. boost::winapi::HANDLE_ hSecondObjectHandle);
  33. #endif
  34. } // extern "C"
  35. #endif
  36. namespace boost {
  37. namespace winapi {
  38. using ::CloseHandle;
  39. using ::DuplicateHandle;
  40. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN10
  41. using ::CompareObjectHandles;
  42. #endif
  43. // Note: MSVC-14.1 does not interpret INVALID_HANDLE_VALUE_ initializer as a constant expression
  44. #if defined( BOOST_USE_WINDOWS_H )
  45. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_CLOSE_SOURCE_ = DUPLICATE_CLOSE_SOURCE;
  46. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_SAME_ACCESS_ = DUPLICATE_SAME_ACCESS;
  47. const HANDLE_ INVALID_HANDLE_VALUE_ = INVALID_HANDLE_VALUE;
  48. #else
  49. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_CLOSE_SOURCE_ = 1;
  50. BOOST_CONSTEXPR_OR_CONST DWORD_ DUPLICATE_SAME_ACCESS_ = 2;
  51. const HANDLE_ INVALID_HANDLE_VALUE_ = (HANDLE_)(-1);
  52. #endif
  53. BOOST_CONSTEXPR_OR_CONST DWORD_ duplicate_close_source = DUPLICATE_CLOSE_SOURCE_;
  54. BOOST_CONSTEXPR_OR_CONST DWORD_ duplicate_same_access = DUPLICATE_SAME_ACCESS_;
  55. // Note: The "unused" attribute here should not be necessary because the variable is a constant.
  56. // However, MinGW gcc 5.3 spams warnings about this particular constant.
  57. const HANDLE_ invalid_handle_value BOOST_ATTRIBUTE_UNUSED = INVALID_HANDLE_VALUE_;
  58. }
  59. }
  60. #include <boost/winapi/detail/footer.hpp>
  61. #endif // BOOST_WINAPI_HANDLES_HPP_INCLUDED_