Win32 API 日本語リファレンス
ホームSystem.Threading › CreateThreadpool

CreateThreadpool

関数
新しいスレッドプールを作成する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

// KERNEL32.dll
#include <windows.h>

PTP_POOL CreateThreadpool(
    void* reserved   // optional
);

パラメーター

名前方向
reservedvoid*optional

戻り値の型: PTP_POOL

各言語での呼び出し定義

// KERNEL32.dll
#include <windows.h>

PTP_POOL CreateThreadpool(
    void* reserved   // optional
);
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateThreadpool(
    IntPtr reserved   // void* optional
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateThreadpool(
    reserved As IntPtr   ' void* optional
) As IntPtr
End Function
' reserved : void* optional
Declare PtrSafe Function CreateThreadpool Lib "kernel32" ( _
    ByVal reserved As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateThreadpool = ctypes.windll.kernel32.CreateThreadpool
CreateThreadpool.restype = ctypes.c_ssize_t
CreateThreadpool.argtypes = [
    ctypes.POINTER(None),  # reserved : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
CreateThreadpool = Fiddle::Function.new(
  lib['CreateThreadpool'],
  [
    Fiddle::TYPE_VOIDP,  # reserved : void* optional
  ],
  Fiddle::TYPE_INTPTR_T)
#[link(name = "kernel32")]
extern "system" {
    fn CreateThreadpool(
        reserved: *mut ()  // void* optional
    ) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern IntPtr CreateThreadpool(IntPtr reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreateThreadpool' -Namespace Win32 -PassThru
# $api::CreateThreadpool(reserved)
#uselib "KERNEL32.dll"
#func global CreateThreadpool "CreateThreadpool" sptr
; CreateThreadpool reserved   ; 戻り値は stat
; reserved : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global CreateThreadpool "CreateThreadpool" sptr
; res = CreateThreadpool(reserved)
; reserved : void* optional -> "sptr"
; PTP_POOL CreateThreadpool(void* reserved)
#uselib "KERNEL32.dll"
#cfunc global CreateThreadpool "CreateThreadpool" intptr
; res = CreateThreadpool(reserved)
; reserved : void* optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procCreateThreadpool = kernel32.NewProc("CreateThreadpool")
)

// reserved (void* optional)
r1, _, err := procCreateThreadpool.Call(
	uintptr(reserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // PTP_POOL
function CreateThreadpool(
  reserved: Pointer   // void* optional
): NativeInt; stdcall;
  external 'KERNEL32.dll' name 'CreateThreadpool';
result := DllCall("KERNEL32\CreateThreadpool"
    , "Ptr", reserved   ; void* optional
    , "Ptr")   ; return: PTP_POOL
●CreateThreadpool(reserved) = DLL("KERNEL32.dll", "int CreateThreadpool(void*)")
# 呼び出し: CreateThreadpool(reserved)
# reserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。