ホーム › System.Threading › CreateThreadpoolIo
CreateThreadpoolIo
関数スレッドプールのI/O完了オブジェクトを作成する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
PTP_IO CreateThreadpoolIo(
HANDLE fl,
PTP_WIN32_IO_CALLBACK pfnio,
void* pv, // optional
TP_CALLBACK_ENVIRON_V3* pcbe // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| fl | HANDLE | in |
| pfnio | PTP_WIN32_IO_CALLBACK | in |
| pv | void* | inoutoptional |
| pcbe | TP_CALLBACK_ENVIRON_V3* | inoptional |
戻り値の型: PTP_IO
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
PTP_IO CreateThreadpoolIo(
HANDLE fl,
PTP_WIN32_IO_CALLBACK pfnio,
void* pv, // optional
TP_CALLBACK_ENVIRON_V3* pcbe // optional
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateThreadpoolIo(
IntPtr fl, // HANDLE
IntPtr pfnio, // PTP_WIN32_IO_CALLBACK
IntPtr pv, // void* optional, in/out
IntPtr pcbe // TP_CALLBACK_ENVIRON_V3* optional
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateThreadpoolIo(
fl As IntPtr, ' HANDLE
pfnio As IntPtr, ' PTP_WIN32_IO_CALLBACK
pv As IntPtr, ' void* optional, in/out
pcbe As IntPtr ' TP_CALLBACK_ENVIRON_V3* optional
) As IntPtr
End Function' fl : HANDLE
' pfnio : PTP_WIN32_IO_CALLBACK
' pv : void* optional, in/out
' pcbe : TP_CALLBACK_ENVIRON_V3* optional
Declare PtrSafe Function CreateThreadpoolIo Lib "kernel32" ( _
ByVal fl As LongPtr, _
ByVal pfnio As LongPtr, _
ByVal pv As LongPtr, _
ByVal pcbe As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreateThreadpoolIo = ctypes.windll.kernel32.CreateThreadpoolIo
CreateThreadpoolIo.restype = ctypes.c_ssize_t
CreateThreadpoolIo.argtypes = [
wintypes.HANDLE, # fl : HANDLE
ctypes.c_void_p, # pfnio : PTP_WIN32_IO_CALLBACK
ctypes.POINTER(None), # pv : void* optional, in/out
ctypes.c_void_p, # pcbe : TP_CALLBACK_ENVIRON_V3* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
CreateThreadpoolIo = Fiddle::Function.new(
lib['CreateThreadpoolIo'],
[
Fiddle::TYPE_VOIDP, # fl : HANDLE
Fiddle::TYPE_VOIDP, # pfnio : PTP_WIN32_IO_CALLBACK
Fiddle::TYPE_VOIDP, # pv : void* optional, in/out
Fiddle::TYPE_VOIDP, # pcbe : TP_CALLBACK_ENVIRON_V3* optional
],
Fiddle::TYPE_INTPTR_T)#[link(name = "kernel32")]
extern "system" {
fn CreateThreadpoolIo(
fl: *mut core::ffi::c_void, // HANDLE
pfnio: *const core::ffi::c_void, // PTP_WIN32_IO_CALLBACK
pv: *mut (), // void* optional, in/out
pcbe: *mut TP_CALLBACK_ENVIRON_V3 // TP_CALLBACK_ENVIRON_V3* optional
) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern IntPtr CreateThreadpoolIo(IntPtr fl, IntPtr pfnio, IntPtr pv, IntPtr pcbe);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreateThreadpoolIo' -Namespace Win32 -PassThru
# $api::CreateThreadpoolIo(fl, pfnio, pv, pcbe)#uselib "KERNEL32.dll"
#func global CreateThreadpoolIo "CreateThreadpoolIo" sptr, sptr, sptr, sptr
; CreateThreadpoolIo fl, pfnio, pv, varptr(pcbe) ; 戻り値は stat
; fl : HANDLE -> "sptr"
; pfnio : PTP_WIN32_IO_CALLBACK -> "sptr"
; pv : void* optional, in/out -> "sptr"
; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global CreateThreadpoolIo "CreateThreadpoolIo" sptr, sptr, sptr, var ; res = CreateThreadpoolIo(fl, pfnio, pv, pcbe) ; fl : HANDLE -> "sptr" ; pfnio : PTP_WIN32_IO_CALLBACK -> "sptr" ; pv : void* optional, in/out -> "sptr" ; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global CreateThreadpoolIo "CreateThreadpoolIo" sptr, sptr, sptr, sptr ; res = CreateThreadpoolIo(fl, pfnio, pv, varptr(pcbe)) ; fl : HANDLE -> "sptr" ; pfnio : PTP_WIN32_IO_CALLBACK -> "sptr" ; pv : void* optional, in/out -> "sptr" ; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; PTP_IO CreateThreadpoolIo(HANDLE fl, PTP_WIN32_IO_CALLBACK pfnio, void* pv, TP_CALLBACK_ENVIRON_V3* pcbe) #uselib "KERNEL32.dll" #cfunc global CreateThreadpoolIo "CreateThreadpoolIo" intptr, intptr, intptr, var ; res = CreateThreadpoolIo(fl, pfnio, pv, pcbe) ; fl : HANDLE -> "intptr" ; pfnio : PTP_WIN32_IO_CALLBACK -> "intptr" ; pv : void* optional, in/out -> "intptr" ; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; PTP_IO CreateThreadpoolIo(HANDLE fl, PTP_WIN32_IO_CALLBACK pfnio, void* pv, TP_CALLBACK_ENVIRON_V3* pcbe) #uselib "KERNEL32.dll" #cfunc global CreateThreadpoolIo "CreateThreadpoolIo" intptr, intptr, intptr, intptr ; res = CreateThreadpoolIo(fl, pfnio, pv, varptr(pcbe)) ; fl : HANDLE -> "intptr" ; pfnio : PTP_WIN32_IO_CALLBACK -> "intptr" ; pv : void* optional, in/out -> "intptr" ; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procCreateThreadpoolIo = kernel32.NewProc("CreateThreadpoolIo")
)
// fl (HANDLE), pfnio (PTP_WIN32_IO_CALLBACK), pv (void* optional, in/out), pcbe (TP_CALLBACK_ENVIRON_V3* optional)
r1, _, err := procCreateThreadpoolIo.Call(
uintptr(fl),
uintptr(pfnio),
uintptr(pv),
uintptr(pcbe),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // PTP_IOfunction CreateThreadpoolIo(
fl: THandle; // HANDLE
pfnio: Pointer; // PTP_WIN32_IO_CALLBACK
pv: Pointer; // void* optional, in/out
pcbe: Pointer // TP_CALLBACK_ENVIRON_V3* optional
): NativeInt; stdcall;
external 'KERNEL32.dll' name 'CreateThreadpoolIo';result := DllCall("KERNEL32\CreateThreadpoolIo"
, "Ptr", fl ; HANDLE
, "Ptr", pfnio ; PTP_WIN32_IO_CALLBACK
, "Ptr", pv ; void* optional, in/out
, "Ptr", pcbe ; TP_CALLBACK_ENVIRON_V3* optional
, "Ptr") ; return: PTP_IO●CreateThreadpoolIo(fl, pfnio, pv, pcbe) = DLL("KERNEL32.dll", "int CreateThreadpoolIo(void*, void*, void*, void*)")
# 呼び出し: CreateThreadpoolIo(fl, pfnio, pv, pcbe)
# fl : HANDLE -> "void*"
# pfnio : PTP_WIN32_IO_CALLBACK -> "void*"
# pv : void* optional, in/out -> "void*"
# pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。