Win32 API 日本語リファレンス
ホームSystem.Threading › CancelWaitableTimer

CancelWaitableTimer

関数
待機可能タイマーの設定を解除して無効化する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

BOOL CancelWaitableTimer(
    HANDLE hTimer
);

パラメーター

名前方向
hTimerHANDLEin

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

BOOL CancelWaitableTimer(
    HANDLE hTimer
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CancelWaitableTimer(
    IntPtr hTimer   // HANDLE
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CancelWaitableTimer(
    hTimer As IntPtr   ' HANDLE
) As Boolean
End Function
' hTimer : HANDLE
Declare PtrSafe Function CancelWaitableTimer Lib "kernel32" ( _
    ByVal hTimer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CancelWaitableTimer = ctypes.windll.kernel32.CancelWaitableTimer
CancelWaitableTimer.restype = wintypes.BOOL
CancelWaitableTimer.argtypes = [
    wintypes.HANDLE,  # hTimer : HANDLE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
CancelWaitableTimer = Fiddle::Function.new(
  lib['CancelWaitableTimer'],
  [
    Fiddle::TYPE_VOIDP,  # hTimer : HANDLE
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn CancelWaitableTimer(
        hTimer: *mut core::ffi::c_void  // HANDLE
    ) -> 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 CancelWaitableTimer(IntPtr hTimer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CancelWaitableTimer' -Namespace Win32 -PassThru
# $api::CancelWaitableTimer(hTimer)
#uselib "KERNEL32.dll"
#func global CancelWaitableTimer "CancelWaitableTimer" sptr
; CancelWaitableTimer hTimer   ; 戻り値は stat
; hTimer : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global CancelWaitableTimer "CancelWaitableTimer" sptr
; res = CancelWaitableTimer(hTimer)
; hTimer : HANDLE -> "sptr"
; BOOL CancelWaitableTimer(HANDLE hTimer)
#uselib "KERNEL32.dll"
#cfunc global CancelWaitableTimer "CancelWaitableTimer" intptr
; res = CancelWaitableTimer(hTimer)
; hTimer : HANDLE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procCancelWaitableTimer = kernel32.NewProc("CancelWaitableTimer")
)

// hTimer (HANDLE)
r1, _, err := procCancelWaitableTimer.Call(
	uintptr(hTimer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CancelWaitableTimer(
  hTimer: THandle   // HANDLE
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'CancelWaitableTimer';
result := DllCall("KERNEL32\CancelWaitableTimer"
    , "Ptr", hTimer   ; HANDLE
    , "Int")   ; return: BOOL
●CancelWaitableTimer(hTimer) = DLL("KERNEL32.dll", "bool CancelWaitableTimer(void*)")
# 呼び出し: CancelWaitableTimer(hTimer)
# hTimer : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。