ホーム › System.Threading › CreateEventA
CreateEventA
関数名前付きまたは無名のイベントを作成する(ANSI版)。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE CreateEventA(
SECURITY_ATTRIBUTES* lpEventAttributes, // optional
BOOL bManualReset,
BOOL bInitialState,
LPCSTR lpName // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpEventAttributes | SECURITY_ATTRIBUTES* | inoptional |
| bManualReset | BOOL | in |
| bInitialState | BOOL | in |
| lpName | LPCSTR | inoptional |
戻り値の型: HANDLE
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE CreateEventA(
SECURITY_ATTRIBUTES* lpEventAttributes, // optional
BOOL bManualReset,
BOOL bInitialState,
LPCSTR lpName // optional
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateEventA(
IntPtr lpEventAttributes, // SECURITY_ATTRIBUTES* optional
bool bManualReset, // BOOL
bool bInitialState, // BOOL
[MarshalAs(UnmanagedType.LPStr)] string lpName // LPCSTR optional
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateEventA(
lpEventAttributes As IntPtr, ' SECURITY_ATTRIBUTES* optional
bManualReset As Boolean, ' BOOL
bInitialState As Boolean, ' BOOL
<MarshalAs(UnmanagedType.LPStr)> lpName As String ' LPCSTR optional
) As IntPtr
End Function' lpEventAttributes : SECURITY_ATTRIBUTES* optional
' bManualReset : BOOL
' bInitialState : BOOL
' lpName : LPCSTR optional
Declare PtrSafe Function CreateEventA Lib "kernel32" ( _
ByVal lpEventAttributes As LongPtr, _
ByVal bManualReset As Long, _
ByVal bInitialState As Long, _
ByVal lpName As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateEventA = ctypes.windll.kernel32.CreateEventA
CreateEventA.restype = ctypes.c_void_p
CreateEventA.argtypes = [
ctypes.c_void_p, # lpEventAttributes : SECURITY_ATTRIBUTES* optional
wintypes.BOOL, # bManualReset : BOOL
wintypes.BOOL, # bInitialState : BOOL
wintypes.LPCSTR, # lpName : LPCSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
CreateEventA = Fiddle::Function.new(
lib['CreateEventA'],
[
Fiddle::TYPE_VOIDP, # lpEventAttributes : SECURITY_ATTRIBUTES* optional
Fiddle::TYPE_INT, # bManualReset : BOOL
Fiddle::TYPE_INT, # bInitialState : BOOL
Fiddle::TYPE_VOIDP, # lpName : LPCSTR optional
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn CreateEventA(
lpEventAttributes: *mut SECURITY_ATTRIBUTES, // SECURITY_ATTRIBUTES* optional
bManualReset: i32, // BOOL
bInitialState: i32, // BOOL
lpName: *const u8 // LPCSTR optional
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr CreateEventA(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, [MarshalAs(UnmanagedType.LPStr)] string lpName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreateEventA' -Namespace Win32 -PassThru
# $api::CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName)#uselib "KERNEL32.dll"
#func global CreateEventA "CreateEventA" sptr, sptr, sptr, sptr
; CreateEventA varptr(lpEventAttributes), bManualReset, bInitialState, lpName ; 戻り値は stat
; lpEventAttributes : SECURITY_ATTRIBUTES* optional -> "sptr"
; bManualReset : BOOL -> "sptr"
; bInitialState : BOOL -> "sptr"
; lpName : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global CreateEventA "CreateEventA" var, int, int, str ; res = CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName) ; lpEventAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; bManualReset : BOOL -> "int" ; bInitialState : BOOL -> "int" ; lpName : LPCSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global CreateEventA "CreateEventA" sptr, int, int, str ; res = CreateEventA(varptr(lpEventAttributes), bManualReset, bInitialState, lpName) ; lpEventAttributes : SECURITY_ATTRIBUTES* optional -> "sptr" ; bManualReset : BOOL -> "int" ; bInitialState : BOOL -> "int" ; lpName : LPCSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HANDLE CreateEventA(SECURITY_ATTRIBUTES* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) #uselib "KERNEL32.dll" #cfunc global CreateEventA "CreateEventA" var, int, int, str ; res = CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName) ; lpEventAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; bManualReset : BOOL -> "int" ; bInitialState : BOOL -> "int" ; lpName : LPCSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HANDLE CreateEventA(SECURITY_ATTRIBUTES* lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCSTR lpName) #uselib "KERNEL32.dll" #cfunc global CreateEventA "CreateEventA" intptr, int, int, str ; res = CreateEventA(varptr(lpEventAttributes), bManualReset, bInitialState, lpName) ; lpEventAttributes : SECURITY_ATTRIBUTES* optional -> "intptr" ; bManualReset : BOOL -> "int" ; bInitialState : BOOL -> "int" ; lpName : LPCSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procCreateEventA = kernel32.NewProc("CreateEventA")
)
// lpEventAttributes (SECURITY_ATTRIBUTES* optional), bManualReset (BOOL), bInitialState (BOOL), lpName (LPCSTR optional)
r1, _, err := procCreateEventA.Call(
uintptr(lpEventAttributes),
uintptr(bManualReset),
uintptr(bInitialState),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction CreateEventA(
lpEventAttributes: Pointer; // SECURITY_ATTRIBUTES* optional
bManualReset: BOOL; // BOOL
bInitialState: BOOL; // BOOL
lpName: PAnsiChar // LPCSTR optional
): THandle; stdcall;
external 'KERNEL32.dll' name 'CreateEventA';result := DllCall("KERNEL32\CreateEventA"
, "Ptr", lpEventAttributes ; SECURITY_ATTRIBUTES* optional
, "Int", bManualReset ; BOOL
, "Int", bInitialState ; BOOL
, "AStr", lpName ; LPCSTR optional
, "Ptr") ; return: HANDLE●CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName) = DLL("KERNEL32.dll", "void* CreateEventA(void*, bool, bool, char*)")
# 呼び出し: CreateEventA(lpEventAttributes, bManualReset, bInitialState, lpName)
# lpEventAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# bManualReset : BOOL -> "bool"
# bInitialState : BOOL -> "bool"
# lpName : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。