ホーム › System.Threading › CreateThreadpoolWait
CreateThreadpoolWait
関数スレッドプールの待機オブジェクトを作成する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
PTP_WAIT CreateThreadpoolWait(
PTP_WAIT_CALLBACK pfnwa,
void* pv, // optional
TP_CALLBACK_ENVIRON_V3* pcbe // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pfnwa | PTP_WAIT_CALLBACK | in |
| pv | void* | inoutoptional |
| pcbe | TP_CALLBACK_ENVIRON_V3* | inoptional |
戻り値の型: PTP_WAIT
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
PTP_WAIT CreateThreadpoolWait(
PTP_WAIT_CALLBACK pfnwa,
void* pv, // optional
TP_CALLBACK_ENVIRON_V3* pcbe // optional
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateThreadpoolWait(
IntPtr pfnwa, // PTP_WAIT_CALLBACK
IntPtr pv, // void* optional, in/out
IntPtr pcbe // TP_CALLBACK_ENVIRON_V3* optional
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateThreadpoolWait(
pfnwa As IntPtr, ' PTP_WAIT_CALLBACK
pv As IntPtr, ' void* optional, in/out
pcbe As IntPtr ' TP_CALLBACK_ENVIRON_V3* optional
) As IntPtr
End Function' pfnwa : PTP_WAIT_CALLBACK
' pv : void* optional, in/out
' pcbe : TP_CALLBACK_ENVIRON_V3* optional
Declare PtrSafe Function CreateThreadpoolWait Lib "kernel32" ( _
ByVal pfnwa 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
CreateThreadpoolWait = ctypes.windll.kernel32.CreateThreadpoolWait
CreateThreadpoolWait.restype = ctypes.c_ssize_t
CreateThreadpoolWait.argtypes = [
ctypes.c_void_p, # pfnwa : PTP_WAIT_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')
CreateThreadpoolWait = Fiddle::Function.new(
lib['CreateThreadpoolWait'],
[
Fiddle::TYPE_VOIDP, # pfnwa : PTP_WAIT_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 CreateThreadpoolWait(
pfnwa: *const core::ffi::c_void, // PTP_WAIT_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 CreateThreadpoolWait(IntPtr pfnwa, IntPtr pv, IntPtr pcbe);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreateThreadpoolWait' -Namespace Win32 -PassThru
# $api::CreateThreadpoolWait(pfnwa, pv, pcbe)#uselib "KERNEL32.dll"
#func global CreateThreadpoolWait "CreateThreadpoolWait" sptr, sptr, sptr
; CreateThreadpoolWait pfnwa, pv, varptr(pcbe) ; 戻り値は stat
; pfnwa : PTP_WAIT_CALLBACK -> "sptr"
; pv : void* optional, in/out -> "sptr"
; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global CreateThreadpoolWait "CreateThreadpoolWait" sptr, sptr, var ; res = CreateThreadpoolWait(pfnwa, pv, pcbe) ; pfnwa : PTP_WAIT_CALLBACK -> "sptr" ; pv : void* optional, in/out -> "sptr" ; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global CreateThreadpoolWait "CreateThreadpoolWait" sptr, sptr, sptr ; res = CreateThreadpoolWait(pfnwa, pv, varptr(pcbe)) ; pfnwa : PTP_WAIT_CALLBACK -> "sptr" ; pv : void* optional, in/out -> "sptr" ; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; PTP_WAIT CreateThreadpoolWait(PTP_WAIT_CALLBACK pfnwa, void* pv, TP_CALLBACK_ENVIRON_V3* pcbe) #uselib "KERNEL32.dll" #cfunc global CreateThreadpoolWait "CreateThreadpoolWait" intptr, intptr, var ; res = CreateThreadpoolWait(pfnwa, pv, pcbe) ; pfnwa : PTP_WAIT_CALLBACK -> "intptr" ; pv : void* optional, in/out -> "intptr" ; pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; PTP_WAIT CreateThreadpoolWait(PTP_WAIT_CALLBACK pfnwa, void* pv, TP_CALLBACK_ENVIRON_V3* pcbe) #uselib "KERNEL32.dll" #cfunc global CreateThreadpoolWait "CreateThreadpoolWait" intptr, intptr, intptr ; res = CreateThreadpoolWait(pfnwa, pv, varptr(pcbe)) ; pfnwa : PTP_WAIT_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")
procCreateThreadpoolWait = kernel32.NewProc("CreateThreadpoolWait")
)
// pfnwa (PTP_WAIT_CALLBACK), pv (void* optional, in/out), pcbe (TP_CALLBACK_ENVIRON_V3* optional)
r1, _, err := procCreateThreadpoolWait.Call(
uintptr(pfnwa),
uintptr(pv),
uintptr(pcbe),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // PTP_WAITfunction CreateThreadpoolWait(
pfnwa: Pointer; // PTP_WAIT_CALLBACK
pv: Pointer; // void* optional, in/out
pcbe: Pointer // TP_CALLBACK_ENVIRON_V3* optional
): NativeInt; stdcall;
external 'KERNEL32.dll' name 'CreateThreadpoolWait';result := DllCall("KERNEL32\CreateThreadpoolWait"
, "Ptr", pfnwa ; PTP_WAIT_CALLBACK
, "Ptr", pv ; void* optional, in/out
, "Ptr", pcbe ; TP_CALLBACK_ENVIRON_V3* optional
, "Ptr") ; return: PTP_WAIT●CreateThreadpoolWait(pfnwa, pv, pcbe) = DLL("KERNEL32.dll", "int CreateThreadpoolWait(void*, void*, void*)")
# 呼び出し: CreateThreadpoolWait(pfnwa, pv, pcbe)
# pfnwa : PTP_WAIT_CALLBACK -> "void*"
# pv : void* optional, in/out -> "void*"
# pcbe : TP_CALLBACK_ENVIRON_V3* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。