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

SetThreadpoolStackInformation

関数
スレッドプールのスタックサイズ情報を設定する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows 7 以降

シグネチャ

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

BOOL SetThreadpoolStackInformation(
    PTP_POOL ptpp,
    TP_POOL_STACK_INFORMATION* ptpsi
);

パラメーター

名前方向
ptppPTP_POOLin
ptpsiTP_POOL_STACK_INFORMATION*in

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetThreadpoolStackInformation(
    PTP_POOL ptpp,
    TP_POOL_STACK_INFORMATION* ptpsi
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetThreadpoolStackInformation(
    IntPtr ptpp,   // PTP_POOL
    IntPtr ptpsi   // TP_POOL_STACK_INFORMATION*
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetThreadpoolStackInformation(
    ptpp As IntPtr,   ' PTP_POOL
    ptpsi As IntPtr   ' TP_POOL_STACK_INFORMATION*
) As Boolean
End Function
' ptpp : PTP_POOL
' ptpsi : TP_POOL_STACK_INFORMATION*
Declare PtrSafe Function SetThreadpoolStackInformation Lib "kernel32" ( _
    ByVal ptpp As LongPtr, _
    ByVal ptpsi As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetThreadpoolStackInformation = ctypes.windll.kernel32.SetThreadpoolStackInformation
SetThreadpoolStackInformation.restype = wintypes.BOOL
SetThreadpoolStackInformation.argtypes = [
    ctypes.c_ssize_t,  # ptpp : PTP_POOL
    ctypes.c_void_p,  # ptpsi : TP_POOL_STACK_INFORMATION*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
SetThreadpoolStackInformation = Fiddle::Function.new(
  lib['SetThreadpoolStackInformation'],
  [
    Fiddle::TYPE_INTPTR_T,  # ptpp : PTP_POOL
    Fiddle::TYPE_VOIDP,  # ptpsi : TP_POOL_STACK_INFORMATION*
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn SetThreadpoolStackInformation(
        ptpp: isize,  // PTP_POOL
        ptpsi: *mut TP_POOL_STACK_INFORMATION  // TP_POOL_STACK_INFORMATION*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool SetThreadpoolStackInformation(IntPtr ptpp, IntPtr ptpsi);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetThreadpoolStackInformation' -Namespace Win32 -PassThru
# $api::SetThreadpoolStackInformation(ptpp, ptpsi)
#uselib "KERNEL32.dll"
#func global SetThreadpoolStackInformation "SetThreadpoolStackInformation" sptr, sptr
; SetThreadpoolStackInformation ptpp, varptr(ptpsi)   ; 戻り値は stat
; ptpp : PTP_POOL -> "sptr"
; ptpsi : TP_POOL_STACK_INFORMATION* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global SetThreadpoolStackInformation "SetThreadpoolStackInformation" sptr, var
; res = SetThreadpoolStackInformation(ptpp, ptpsi)
; ptpp : PTP_POOL -> "sptr"
; ptpsi : TP_POOL_STACK_INFORMATION* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetThreadpoolStackInformation(PTP_POOL ptpp, TP_POOL_STACK_INFORMATION* ptpsi)
#uselib "KERNEL32.dll"
#cfunc global SetThreadpoolStackInformation "SetThreadpoolStackInformation" intptr, var
; res = SetThreadpoolStackInformation(ptpp, ptpsi)
; ptpp : PTP_POOL -> "intptr"
; ptpsi : TP_POOL_STACK_INFORMATION* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procSetThreadpoolStackInformation = kernel32.NewProc("SetThreadpoolStackInformation")
)

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