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

SetUmsThreadInformation

関数
指定のUMSスレッドに情報を設定する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSWindows 7 以降

シグネチャ

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

BOOL SetUmsThreadInformation(
    void* UmsThread,
    UMS_THREAD_INFO_CLASS UmsThreadInfoClass,
    void* UmsThreadInformation,
    DWORD UmsThreadInformationLength
);

パラメーター

名前方向
UmsThreadvoid*in
UmsThreadInfoClassUMS_THREAD_INFO_CLASSin
UmsThreadInformationvoid*in
UmsThreadInformationLengthDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetUmsThreadInformation(
    void* UmsThread,
    UMS_THREAD_INFO_CLASS UmsThreadInfoClass,
    void* UmsThreadInformation,
    DWORD UmsThreadInformationLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetUmsThreadInformation(
    IntPtr UmsThread,   // void*
    int UmsThreadInfoClass,   // UMS_THREAD_INFO_CLASS
    IntPtr UmsThreadInformation,   // void*
    uint UmsThreadInformationLength   // DWORD
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetUmsThreadInformation(
    UmsThread As IntPtr,   ' void*
    UmsThreadInfoClass As Integer,   ' UMS_THREAD_INFO_CLASS
    UmsThreadInformation As IntPtr,   ' void*
    UmsThreadInformationLength As UInteger   ' DWORD
) As Boolean
End Function
' UmsThread : void*
' UmsThreadInfoClass : UMS_THREAD_INFO_CLASS
' UmsThreadInformation : void*
' UmsThreadInformationLength : DWORD
Declare PtrSafe Function SetUmsThreadInformation Lib "kernel32" ( _
    ByVal UmsThread As LongPtr, _
    ByVal UmsThreadInfoClass As Long, _
    ByVal UmsThreadInformation As LongPtr, _
    ByVal UmsThreadInformationLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetUmsThreadInformation = ctypes.windll.kernel32.SetUmsThreadInformation
SetUmsThreadInformation.restype = wintypes.BOOL
SetUmsThreadInformation.argtypes = [
    ctypes.POINTER(None),  # UmsThread : void*
    ctypes.c_int,  # UmsThreadInfoClass : UMS_THREAD_INFO_CLASS
    ctypes.POINTER(None),  # UmsThreadInformation : void*
    wintypes.DWORD,  # UmsThreadInformationLength : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
SetUmsThreadInformation = Fiddle::Function.new(
  lib['SetUmsThreadInformation'],
  [
    Fiddle::TYPE_VOIDP,  # UmsThread : void*
    Fiddle::TYPE_INT,  # UmsThreadInfoClass : UMS_THREAD_INFO_CLASS
    Fiddle::TYPE_VOIDP,  # UmsThreadInformation : void*
    -Fiddle::TYPE_INT,  # UmsThreadInformationLength : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn SetUmsThreadInformation(
        UmsThread: *mut (),  // void*
        UmsThreadInfoClass: i32,  // UMS_THREAD_INFO_CLASS
        UmsThreadInformation: *mut (),  // void*
        UmsThreadInformationLength: u32  // DWORD
    ) -> 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 SetUmsThreadInformation(IntPtr UmsThread, int UmsThreadInfoClass, IntPtr UmsThreadInformation, uint UmsThreadInformationLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetUmsThreadInformation' -Namespace Win32 -PassThru
# $api::SetUmsThreadInformation(UmsThread, UmsThreadInfoClass, UmsThreadInformation, UmsThreadInformationLength)
#uselib "KERNEL32.dll"
#func global SetUmsThreadInformation "SetUmsThreadInformation" sptr, sptr, sptr, sptr
; SetUmsThreadInformation UmsThread, UmsThreadInfoClass, UmsThreadInformation, UmsThreadInformationLength   ; 戻り値は stat
; UmsThread : void* -> "sptr"
; UmsThreadInfoClass : UMS_THREAD_INFO_CLASS -> "sptr"
; UmsThreadInformation : void* -> "sptr"
; UmsThreadInformationLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global SetUmsThreadInformation "SetUmsThreadInformation" sptr, int, sptr, int
; res = SetUmsThreadInformation(UmsThread, UmsThreadInfoClass, UmsThreadInformation, UmsThreadInformationLength)
; UmsThread : void* -> "sptr"
; UmsThreadInfoClass : UMS_THREAD_INFO_CLASS -> "int"
; UmsThreadInformation : void* -> "sptr"
; UmsThreadInformationLength : DWORD -> "int"
; BOOL SetUmsThreadInformation(void* UmsThread, UMS_THREAD_INFO_CLASS UmsThreadInfoClass, void* UmsThreadInformation, DWORD UmsThreadInformationLength)
#uselib "KERNEL32.dll"
#cfunc global SetUmsThreadInformation "SetUmsThreadInformation" intptr, int, intptr, int
; res = SetUmsThreadInformation(UmsThread, UmsThreadInfoClass, UmsThreadInformation, UmsThreadInformationLength)
; UmsThread : void* -> "intptr"
; UmsThreadInfoClass : UMS_THREAD_INFO_CLASS -> "int"
; UmsThreadInformation : void* -> "intptr"
; UmsThreadInformationLength : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procSetUmsThreadInformation = kernel32.NewProc("SetUmsThreadInformation")
)

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