win32_api.hpp

来自「Boost provides free peer-reviewed portab」· HPP 代码 · 共 427 行 · 第 1/2 页

HPP
427
字号
////////////////////////////////////////////////////////////////////////////////// (C) Copyright Ion Gaztanaga 2005-2008. Distributed under the Boost// Software License, Version 1.0. (See accompanying file// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)//// See http://www.boost.org/libs/interprocess for documentation.////////////////////////////////////////////////////////////////////////////////#ifndef BOOST_INTERPROCESS_WIN32_SYNC_PRIMITIVES_HPP#define BOOST_INTERPROCESS_WIN32_SYNC_PRIMITIVES_HPP#include <boost/interprocess/detail/config_begin.hpp>#include <boost/interprocess/detail/workaround.hpp>#include <cstddef>#if (defined _MSC_VER) && (_MSC_VER >= 1200)#  pragma once#  pragma comment( lib, "advapi32.lib" )#endif#if (defined BOOST_WINDOWS) && !(defined BOOST_DISABLE_WIN32)#  include <cstdarg>#  include <boost/detail/interlocked.hpp>#else# error "This file can only be included in Windows OS"#endif//The structures used in Interprocess with the//same binary interface as windows onesnamespace boost {namespace interprocess {namespace winapi {//Some used constantsstatic const unsigned long infinite_time        = 0xFFFFFFFF;static const unsigned long error_already_exists = 183L;static const unsigned long error_file_not_found = 2u;static const unsigned long semaphore_all_access = (0x000F0000L)|(0x00100000L)|0x3;static const unsigned long mutex_all_access     = (0x000F0000L)|(0x00100000L)|0x0001;static const unsigned long page_readonly        = 0x02;static const unsigned long page_readwrite       = 0x04;static const unsigned long page_writecopy       = 0x08;static const unsigned long standard_rights_required   = 0x000F0000L;static const unsigned long section_query              = 0x0001;static const unsigned long section_map_write          = 0x0002;static const unsigned long section_map_read           = 0x0004;static const unsigned long section_map_execute        = 0x0008;static const unsigned long section_extend_size        = 0x0010;static const unsigned long section_all_access         = standard_rights_required |                                                        section_query            |                                                        section_map_write        |                                                        section_map_read         |                                                        section_map_execute      |                                                        section_extend_size;static const unsigned long file_map_copy        = section_query;static const unsigned long file_map_write       = section_map_write;static const unsigned long file_map_read        = section_map_read;static const unsigned long file_map_all_access  = section_all_access;static const unsigned long movefile_copy_allowed            = 0x02;static const unsigned long movefile_delay_until_reboot      = 0x04;static const unsigned long movefile_replace_existing        = 0x01;static const unsigned long movefile_write_through           = 0x08;static const unsigned long movefile_create_hardlink         = 0x10;static const unsigned long movefile_fail_if_not_trackable   = 0x20;static const unsigned long file_share_read      = 0x00000001;static const unsigned long file_share_write     = 0x00000002;static const unsigned long file_share_delete    = 0x00000004;static const unsigned long generic_read         = 0x80000000L;static const unsigned long generic_write        = 0x40000000L;static const unsigned long wait_object_0        = 0;static const unsigned long wait_abandoned       = 0x00000080L;static const unsigned long wait_timeout         = 258L;static const unsigned long wait_failed          = (unsigned long)0xFFFFFFFF;static const unsigned long duplicate_close_source  = (unsigned long)0x00000001;static const unsigned long duplicate_same_access   = (unsigned long)0x00000002;static const unsigned long format_message_allocate_buffer   = (unsigned long)0x00000100;static const unsigned long format_message_ignore_inserts   = (unsigned long)0x00000200;static const unsigned long format_message_from_string   = (unsigned long)0x00000400;static const unsigned long format_message_from_hmodule   = (unsigned long)0x00000800;static const unsigned long format_message_from_system   = (unsigned long)0x00001000;static const unsigned long format_message_argument_array   = (unsigned long)0x00002000;static const unsigned long format_message_max_width_mask   = (unsigned long)0x000000FF;static const unsigned long lang_neutral         = (unsigned long)0x00;static const unsigned long sublang_default      = (unsigned long)0x01;static const unsigned long invalid_file_size    = (unsigned long)0xFFFFFFFF;static       void * const  invalid_handle_value = (void*)(long)(-1);static const unsigned long create_new        = 1;static const unsigned long create_always     = 2;static const unsigned long open_existing     = 3;static const unsigned long open_always       = 4;static const unsigned long truncate_existing = 5;static const unsigned long file_attribute_temporary = 0x00000100;static const unsigned long file_begin     = 0;static const unsigned long file_current   = 1;static const unsigned long file_end       = 2;static const unsigned long lockfile_fail_immediately  = 1;static const unsigned long lockfile_exclusive_lock    = 2;static const unsigned long error_lock_violation       = 33;static const unsigned long security_descriptor_revision = 1;}  //namespace winapi {}  //namespace interprocess  {}  //namespace boost  {#if !defined( BOOST_USE_WINDOWS_H )namespace boost  {namespace interprocess  {namespace winapi {struct interprocess_overlapped {   unsigned long *internal;   unsigned long *internal_high;   union {      struct {         unsigned long offset;         unsigned long offset_high;      }dummy;      void *pointer;   };   void *h_event;};struct interprocess_filetime{     unsigned long  dwLowDateTime;     unsigned long  dwHighDateTime;};struct interprocess_security_attributes{   unsigned long nLength;   void *lpSecurityDescriptor;   int bInheritHandle;};struct system_info {    union {        unsigned long dwOemId;          // Obsolete field...do not use        struct {            unsigned short wProcessorArchitecture;            unsigned short wReserved;        } dummy;    };    unsigned long dwPageSize;    void * lpMinimumApplicationAddress;    void * lpMaximumApplicationAddress;    unsigned long * dwActiveProcessorMask;    unsigned long dwNumberOfProcessors;    unsigned long dwProcessorType;    unsigned long dwAllocationGranularity;    unsigned short wProcessorLevel;    unsigned short wProcessorRevision;};struct interprocess_memory_basic_information{   void *         BaseAddress;     void *         AllocationBase;   unsigned long  AllocationProtect;   unsigned long  RegionSize;   unsigned long  State;   unsigned long  Protect;   unsigned long  Type;};typedef struct _interprocess_acl{   unsigned char  AclRevision;   unsigned char  Sbz1;   unsigned short AclSize;   unsigned short AceCount;   unsigned short Sbz2;} interprocess_acl;typedef struct _interprocess_security_descriptor{   unsigned char Revision;   unsigned char Sbz1;   unsigned short Control;   void *Owner;   void *Group;   interprocess_acl *Sacl;   interprocess_acl *Dacl;} interprocess_security_descriptor;//Some windows API declarationsextern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentProcessId();extern "C" __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId();extern "C" __declspec(dllimport) void __stdcall Sleep(unsigned long);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?