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