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