Back to Arangodb

Using Boost.WinAPI

3rdParty/boost/1.78.0/libs/winapi/doc/html/winapi/usage.html

3.12.9.22.6 KB
Original Source

| | Home | Libraries | People | FAQ | More |


Using Boost.WinAPI

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 char or wchar_t based functions depending on the UNICODE macro. Boost.WinAPI also does not support _TCHAR and related string types. Users have to explicitly use the *A or *W functions with appropriate argument types. Note however that *A functions may not be available if BOOST_NO_ANSI_APIS is defined.

|

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 attributes0l,// initial countstd::numeric\_limits\<boost::winapi::LONG\_\>::max(),// max countL"Local\\MySemaphore",// semaphore name0l,// flagsboost::winapi::SEMAPHORE\_ALL\_ACCESS\_// access mode);if(h)boost::winapi::CloseHandle(h);

Refer to MSDN for documentation on the particular functions, types and constants.

| | Copyright © 2016-2018 Andrey Semashev

Distributed under the Boost Software License, Version 1.0.

|