ホーム › System.Diagnostics.ToolHelp › THREADENTRY32
THREADENTRY32
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwSize | DWORD | 4 | +0 | +0 | 本構造体のバイトサイズ。Thread32First前に設定が必要。 |
| cntUsage | DWORD | 4 | +4 | +4 | 未使用。常に0。 |
| th32ThreadID | DWORD | 4 | +8 | +8 | スレッドのID。 |
| th32OwnerProcessID | DWORD | 4 | +12 | +12 | スレッドを所有するプロセスのID。 |
| tpBasePri | INT | 4 | +16 | +16 | スレッドの基本優先度。 |
| tpDeltaPri | INT | 4 | +20 | +20 | 未使用。常に0。 |
| dwFlags | DWORD | 4 | +24 | +24 | 未使用。常に0。 |
各言語での定義
#include <windows.h>
// THREADENTRY32 (x64 28 / x86 28 バイト)
typedef struct THREADENTRY32 {
DWORD dwSize;
DWORD cntUsage;
DWORD th32ThreadID;
DWORD th32OwnerProcessID;
INT tpBasePri;
INT tpDeltaPri;
DWORD dwFlags;
} THREADENTRY32;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct THREADENTRY32
{
public uint dwSize;
public uint cntUsage;
public uint th32ThreadID;
public uint th32OwnerProcessID;
public int tpBasePri;
public int tpDeltaPri;
public uint dwFlags;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure THREADENTRY32
Public dwSize As UInteger
Public cntUsage As UInteger
Public th32ThreadID As UInteger
Public th32OwnerProcessID As UInteger
Public tpBasePri As Integer
Public tpDeltaPri As Integer
Public dwFlags As UInteger
End Structureimport ctypes
from ctypes import wintypes
class THREADENTRY32(ctypes.Structure):
_fields_ = [
("dwSize", wintypes.DWORD),
("cntUsage", wintypes.DWORD),
("th32ThreadID", wintypes.DWORD),
("th32OwnerProcessID", wintypes.DWORD),
("tpBasePri", ctypes.c_int),
("tpDeltaPri", ctypes.c_int),
("dwFlags", wintypes.DWORD),
]#[repr(C)]
pub struct THREADENTRY32 {
pub dwSize: u32,
pub cntUsage: u32,
pub th32ThreadID: u32,
pub th32OwnerProcessID: u32,
pub tpBasePri: i32,
pub tpDeltaPri: i32,
pub dwFlags: u32,
}import "golang.org/x/sys/windows"
type THREADENTRY32 struct {
dwSize uint32
cntUsage uint32
th32ThreadID uint32
th32OwnerProcessID uint32
tpBasePri int32
tpDeltaPri int32
dwFlags uint32
}type
THREADENTRY32 = record
dwSize: DWORD;
cntUsage: DWORD;
th32ThreadID: DWORD;
th32OwnerProcessID: DWORD;
tpBasePri: Integer;
tpDeltaPri: Integer;
dwFlags: DWORD;
end;const THREADENTRY32 = extern struct {
dwSize: u32,
cntUsage: u32,
th32ThreadID: u32,
th32OwnerProcessID: u32,
tpBasePri: i32,
tpDeltaPri: i32,
dwFlags: u32,
};type
THREADENTRY32 {.bycopy.} = object
dwSize: uint32
cntUsage: uint32
th32ThreadID: uint32
th32OwnerProcessID: uint32
tpBasePri: int32
tpDeltaPri: int32
dwFlags: uint32struct THREADENTRY32
{
uint dwSize;
uint cntUsage;
uint th32ThreadID;
uint th32OwnerProcessID;
int tpBasePri;
int tpDeltaPri;
uint dwFlags;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; THREADENTRY32 サイズ: 28 バイト(x64)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; cntUsage : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; th32ThreadID : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; th32OwnerProcessID : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; tpBasePri : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; tpDeltaPri : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwFlags : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global THREADENTRY32
#field int dwSize
#field int cntUsage
#field int th32ThreadID
#field int th32OwnerProcessID
#field int tpBasePri
#field int tpDeltaPri
#field int dwFlags
#endstruct
stdim st, THREADENTRY32 ; NSTRUCT 変数を確保
st->dwSize = 100
mes "dwSize=" + st->dwSize