ホーム › Devices.Communication › GetCommMask
GetCommMask
関数指定した通信デバイスで監視中のイベントマスクの値を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL GetCommMask(
HANDLE hFile,
COMM_EVENT_MASK* lpEvtMask
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hFile | HANDLE | in |
| lpEvtMask | COMM_EVENT_MASK* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL GetCommMask(
HANDLE hFile,
COMM_EVENT_MASK* lpEvtMask
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetCommMask(
IntPtr hFile, // HANDLE
out uint lpEvtMask // COMM_EVENT_MASK* out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetCommMask(
hFile As IntPtr, ' HANDLE
<Out> ByRef lpEvtMask As UInteger ' COMM_EVENT_MASK* out
) As Boolean
End Function' hFile : HANDLE
' lpEvtMask : COMM_EVENT_MASK* out
Declare PtrSafe Function GetCommMask Lib "kernel32" ( _
ByVal hFile As LongPtr, _
ByRef lpEvtMask As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetCommMask = ctypes.windll.kernel32.GetCommMask
GetCommMask.restype = wintypes.BOOL
GetCommMask.argtypes = [
wintypes.HANDLE, # hFile : HANDLE
ctypes.c_void_p, # lpEvtMask : COMM_EVENT_MASK* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetCommMask = Fiddle::Function.new(
lib['GetCommMask'],
[
Fiddle::TYPE_VOIDP, # hFile : HANDLE
Fiddle::TYPE_VOIDP, # lpEvtMask : COMM_EVENT_MASK* out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetCommMask(
hFile: *mut core::ffi::c_void, // HANDLE
lpEvtMask: *mut u32 // COMM_EVENT_MASK* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool GetCommMask(IntPtr hFile, out uint lpEvtMask);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetCommMask' -Namespace Win32 -PassThru
# $api::GetCommMask(hFile, lpEvtMask)#uselib "KERNEL32.dll"
#func global GetCommMask "GetCommMask" sptr, sptr
; GetCommMask hFile, lpEvtMask ; 戻り値は stat
; hFile : HANDLE -> "sptr"
; lpEvtMask : COMM_EVENT_MASK* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global GetCommMask "GetCommMask" sptr, int
; res = GetCommMask(hFile, lpEvtMask)
; hFile : HANDLE -> "sptr"
; lpEvtMask : COMM_EVENT_MASK* out -> "int"; BOOL GetCommMask(HANDLE hFile, COMM_EVENT_MASK* lpEvtMask)
#uselib "KERNEL32.dll"
#cfunc global GetCommMask "GetCommMask" intptr, int
; res = GetCommMask(hFile, lpEvtMask)
; hFile : HANDLE -> "intptr"
; lpEvtMask : COMM_EVENT_MASK* out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetCommMask = kernel32.NewProc("GetCommMask")
)
// hFile (HANDLE), lpEvtMask (COMM_EVENT_MASK* out)
r1, _, err := procGetCommMask.Call(
uintptr(hFile),
uintptr(lpEvtMask),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetCommMask(
hFile: THandle; // HANDLE
lpEvtMask: Pointer // COMM_EVENT_MASK* out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'GetCommMask';result := DllCall("KERNEL32\GetCommMask"
, "Ptr", hFile ; HANDLE
, "Ptr", lpEvtMask ; COMM_EVENT_MASK* out
, "Int") ; return: BOOL●GetCommMask(hFile, lpEvtMask) = DLL("KERNEL32.dll", "bool GetCommMask(void*, void*)")
# 呼び出し: GetCommMask(hFile, lpEvtMask)
# hFile : HANDLE -> "void*"
# lpEvtMask : COMM_EVENT_MASK* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。