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