CancelIo
関数現在のスレッドが発行した保留中のI/Oをキャンセルする。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL CancelIo(
HANDLE hFile
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hFile | HANDLE | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL CancelIo(
HANDLE hFile
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool CancelIo(
IntPtr hFile // HANDLE
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CancelIo(
hFile As IntPtr ' HANDLE
) As Boolean
End Function' hFile : HANDLE
Declare PtrSafe Function CancelIo Lib "kernel32" ( _
ByVal hFile As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CancelIo = ctypes.windll.kernel32.CancelIo
CancelIo.restype = wintypes.BOOL
CancelIo.argtypes = [
wintypes.HANDLE, # hFile : HANDLE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
CancelIo = Fiddle::Function.new(
lib['CancelIo'],
[
Fiddle::TYPE_VOIDP, # hFile : HANDLE
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn CancelIo(
hFile: *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 CancelIo(IntPtr hFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CancelIo' -Namespace Win32 -PassThru
# $api::CancelIo(hFile)#uselib "KERNEL32.dll"
#func global CancelIo "CancelIo" sptr
; CancelIo hFile ; 戻り値は stat
; hFile : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global CancelIo "CancelIo" sptr
; res = CancelIo(hFile)
; hFile : HANDLE -> "sptr"; BOOL CancelIo(HANDLE hFile)
#uselib "KERNEL32.dll"
#cfunc global CancelIo "CancelIo" intptr
; res = CancelIo(hFile)
; hFile : HANDLE -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procCancelIo = kernel32.NewProc("CancelIo")
)
// hFile (HANDLE)
r1, _, err := procCancelIo.Call(
uintptr(hFile),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CancelIo(
hFile: THandle // HANDLE
): BOOL; stdcall;
external 'KERNEL32.dll' name 'CancelIo';result := DllCall("KERNEL32\CancelIo"
, "Ptr", hFile ; HANDLE
, "Int") ; return: BOOL●CancelIo(hFile) = DLL("KERNEL32.dll", "bool CancelIo(void*)")
# 呼び出し: CancelIo(hFile)
# hFile : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。