Boost
C++ Libraries
...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
This is an older version of Boost and was released in 2024. The current version is 1.90.0.
In order to use Boost.WinAPI you have to include one or several headers from
the boost/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::winapi
namespace. User's code is supposed to use the symbols from the boost::winapi
namespace only.
Most of the functions in the boost::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/winapi/handles.hpp> #include <boost/winapi/semaphore.hpp> boost::winapi::HANDLE_ h = boost::winapi::CreateSemaphoreExW( NULL, // security attributes 0l, // initial count std::numeric_limits< boost::winapi::LONG_ >::max(), // max count L"Local\\MySemaphore", // semaphore name 0l, // flags boost::winapi::SEMAPHORE_ALL_ACCESS_ // access mode ); if (h) boost::winapi::CloseHandle(h);
Refer to MSDN for documentation on the particular functions, types and constants.