ホーム › System.Diagnostics.ToolHelp › PROCESSENTRY32W
PROCESSENTRY32W
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwSize | DWORD | 4 | +0 | +0 | 本構造体のバイトサイズ。Process32FirstW前に設定が必要。 |
| cntUsage | DWORD | 4 | +4 | +4 | 未使用。常に0。 |
| th32ProcessID | DWORD | 4 | +8 | +8 | プロセスのID。 |
| th32DefaultHeapID | UINT_PTR | 8/4 | +16 | +12 | プロセスの既定ヒープID。未使用。 |
| th32ModuleID | DWORD | 4 | +24 | +16 | 未使用。常に0。 |
| cntThreads | DWORD | 4 | +28 | +20 | プロセスが開始したスレッド数。 |
| th32ParentProcessID | DWORD | 4 | +32 | +24 | 親プロセスのID。 |
| pcPriClassBase | INT | 4 | +36 | +28 | プロセスの基本優先度クラス。 |
| dwFlags | DWORD | 4 | +40 | +32 | 未使用。常に0。 |
| szExeFile | WCHAR | 520 | +44 | +36 | 実行ファイル名(ワイド文字列)。 |
各言語での定義
#include <windows.h>
// PROCESSENTRY32W (x64 568 / x86 556 バイト)
typedef struct PROCESSENTRY32W {
DWORD dwSize;
DWORD cntUsage;
DWORD th32ProcessID;
UINT_PTR th32DefaultHeapID;
DWORD th32ModuleID;
DWORD cntThreads;
DWORD th32ParentProcessID;
INT pcPriClassBase;
DWORD dwFlags;
WCHAR szExeFile[260];
} PROCESSENTRY32W;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PROCESSENTRY32W
{
public uint dwSize;
public uint cntUsage;
public uint th32ProcessID;
public UIntPtr th32DefaultHeapID;
public uint th32ModuleID;
public uint cntThreads;
public uint th32ParentProcessID;
public int pcPriClassBase;
public uint dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szExeFile;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PROCESSENTRY32W
Public dwSize As UInteger
Public cntUsage As UInteger
Public th32ProcessID As UInteger
Public th32DefaultHeapID As UIntPtr
Public th32ModuleID As UInteger
Public cntThreads As UInteger
Public th32ParentProcessID As UInteger
Public pcPriClassBase As Integer
Public dwFlags As UInteger
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> Public szExeFile As String
End Structureimport ctypes
from ctypes import wintypes
class PROCESSENTRY32W(ctypes.Structure):
_fields_ = [
("dwSize", wintypes.DWORD),
("cntUsage", wintypes.DWORD),
("th32ProcessID", wintypes.DWORD),
("th32DefaultHeapID", ctypes.c_size_t),
("th32ModuleID", wintypes.DWORD),
("cntThreads", wintypes.DWORD),
("th32ParentProcessID", wintypes.DWORD),
("pcPriClassBase", ctypes.c_int),
("dwFlags", wintypes.DWORD),
("szExeFile", ctypes.c_wchar * 260),
]#[repr(C)]
pub struct PROCESSENTRY32W {
pub dwSize: u32,
pub cntUsage: u32,
pub th32ProcessID: u32,
pub th32DefaultHeapID: usize,
pub th32ModuleID: u32,
pub cntThreads: u32,
pub th32ParentProcessID: u32,
pub pcPriClassBase: i32,
pub dwFlags: u32,
pub szExeFile: [u16; 260],
}import "golang.org/x/sys/windows"
type PROCESSENTRY32W struct {
dwSize uint32
cntUsage uint32
th32ProcessID uint32
th32DefaultHeapID uintptr
th32ModuleID uint32
cntThreads uint32
th32ParentProcessID uint32
pcPriClassBase int32
dwFlags uint32
szExeFile [260]uint16
}type
PROCESSENTRY32W = record
dwSize: DWORD;
cntUsage: DWORD;
th32ProcessID: DWORD;
th32DefaultHeapID: NativeUInt;
th32ModuleID: DWORD;
cntThreads: DWORD;
th32ParentProcessID: DWORD;
pcPriClassBase: Integer;
dwFlags: DWORD;
szExeFile: array[0..259] of WideChar;
end;const PROCESSENTRY32W = extern struct {
dwSize: u32,
cntUsage: u32,
th32ProcessID: u32,
th32DefaultHeapID: usize,
th32ModuleID: u32,
cntThreads: u32,
th32ParentProcessID: u32,
pcPriClassBase: i32,
dwFlags: u32,
szExeFile: [260]u16,
};type
PROCESSENTRY32W {.bycopy.} = object
dwSize: uint32
cntUsage: uint32
th32ProcessID: uint32
th32DefaultHeapID: uint
th32ModuleID: uint32
cntThreads: uint32
th32ParentProcessID: uint32
pcPriClassBase: int32
dwFlags: uint32
szExeFile: array[260, uint16]struct PROCESSENTRY32W
{
uint dwSize;
uint cntUsage;
uint th32ProcessID;
size_t th32DefaultHeapID;
uint th32ModuleID;
uint cntThreads;
uint th32ParentProcessID;
int pcPriClassBase;
uint dwFlags;
wchar[260] szExeFile;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PROCESSENTRY32W サイズ: 556 バイト(x86)
dim st, 139 ; 4byte整数×139(構造体サイズ 556 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; cntUsage : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; th32ProcessID : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; th32DefaultHeapID : UINT_PTR (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; th32ModuleID : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; cntThreads : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; th32ParentProcessID : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; pcPriClassBase : INT (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; dwFlags : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; szExeFile : WCHAR (+36, 520byte) varptr(st)+36 を基点に操作(520byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PROCESSENTRY32W サイズ: 568 バイト(x64)
dim st, 142 ; 4byte整数×142(構造体サイズ 568 / 4 切り上げ)
; dwSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; cntUsage : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; th32ProcessID : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; th32DefaultHeapID : UINT_PTR (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; th32ModuleID : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; cntThreads : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; th32ParentProcessID : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; pcPriClassBase : INT (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; dwFlags : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; szExeFile : WCHAR (+44, 520byte) varptr(st)+44 を基点に操作(520byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PROCESSENTRY32W
#field int dwSize
#field int cntUsage
#field int th32ProcessID
#field intptr th32DefaultHeapID
#field int th32ModuleID
#field int cntThreads
#field int th32ParentProcessID
#field int pcPriClassBase
#field int dwFlags
#field wchar szExeFile 260
#endstruct
stdim st, PROCESSENTRY32W ; NSTRUCT 変数を確保
st->dwSize = 100
mes "dwSize=" + st->dwSize