...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
In order to use Boost.WinAPI you have to include one or several headers from
the boost/detail/winapi
directory. Each header there defines a portion of Windows API, the name of
the header should be self-explanatory. Each Boost.WinAPI header may declare
a number of symbols like functions and types in the global namespace, mimicking
the Windows SDK, and the corresponding set of symbols in the boost::detail::winapi
namespace. User's code is supposed to use the symbols from the boost::detail::winapi
namespace only.
Most of the functions in the boost::detail::winapi
have the same name and meaning as the corresponding Windows API functions.
Types and constants have a trailing underscore ('_') in their name to avoid
clashes with macros that are defined in Windows SDK.
Note | |
---|---|
Boost.WinAPI does not define function-name macros that expand to the |
For example, here is how one would create and destroy a semaphore with Boost.WinAPI:
#include <limits> #include <boost/detail/winapi/handles.hpp> #include <boost/detail/winapi/semaphore.hpp> boost::detail::winapi::HANDLE_ h = boost::detail::winapi::CreateSemaphoreExW( NULL, // security attributes 0l, // initial count std::numeric_limits< boost::detail::winapi::LONG_ >::max(), // max count L"Local\\MySemaphore", // semaphore name 0l, // flags boost::detail::winapi::SEMAPHORE_ALL_ACCESS_ // access mode ); if (h) boost::detail::winapi::CloseHandle(h);
Refer to MSDN for documentation on the particular functions, types and constants.