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