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