ホーム › System.Performance › PDH_COUNTER_INFO_A
PDH_COUNTER_INFO_A
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwLength | DWORD | 4 | +0 | +0 | この構造体と付随データの合計バイト長である。 |
| dwType | DWORD | 4 | +4 | +4 | カウンタの種類(PERF_COUNTER_系)を示す。 |
| CVersion | DWORD | 4 | +8 | +8 | カウンタを提供するDLLのバージョンである。 |
| CStatus | DWORD | 4 | +12 | +12 | カウンタのステータスコード(PDH_CSTATUS値)である。 |
| lScale | INT | 4 | +16 | +16 | カウンタに適用するスケール(10のべき乗指数)である。 |
| lDefaultScale | INT | 4 | +20 | +20 | カウンタの既定スケール(10のべき乗指数)である。 |
| dwUserData | UINT_PTR | 8/4 | +24 | +24 | カウンタに関連付けられたユーザーデータである。 |
| dwQueryUserData | UINT_PTR | 8/4 | +32 | +28 | クエリに関連付けられたユーザーデータである。 |
| szFullPath | LPSTR | 8/4 | +40 | +32 | カウンタの完全パス文字列(ANSI)である。 |
| Anonymous | _Anonymous_e__Union | 48/28 | +48 | +36 | パスを構成する各要素(マシン/オブジェクト/インスタンス/カウンタ名等)を保持する共用体である。 |
| szExplainText | LPSTR | 8/4 | +96 | +64 | カウンタの説明テキスト(ANSI)である。 |
| DataBuffer | DWORD | 4 | +104 | +68 | 可変長データを格納するバッファ先頭(プレースホルダ)である。 |
共用体: _Anonymous_e__Union x64 48B / x86 28B
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| DataItemPath | PDH_DATA_ITEM_PATH_ELEMENTS_A | 40/28 | +0 | +0 | |
| CounterPath | PDH_COUNTER_PATH_ELEMENTS_A | 48/24 | +0 | +0 | |
| Anonymous | _Anonymous_e__Struct | 8/4 | +0 | +0 | パスを構成する各要素(マシン/オブジェクト/インスタンス/カウンタ名等)を保持する共用体である。 |
各言語での定義
#include <windows.h>
// PDH_COUNTER_INFO_A (x64 112 / x86 72 バイト)
typedef struct PDH_COUNTER_INFO_A {
DWORD dwLength;
DWORD dwType;
DWORD CVersion;
DWORD CStatus;
INT lScale;
INT lDefaultScale;
UINT_PTR dwUserData;
UINT_PTR dwQueryUserData;
LPSTR szFullPath;
_Anonymous_e__Union Anonymous;
LPSTR szExplainText;
DWORD DataBuffer[1];
} PDH_COUNTER_INFO_A;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PDH_COUNTER_INFO_A
{
public uint dwLength;
public uint dwType;
public uint CVersion;
public uint CStatus;
public int lScale;
public int lDefaultScale;
public UIntPtr dwUserData;
public UIntPtr dwQueryUserData;
public IntPtr szFullPath;
public _Anonymous_e__Union Anonymous;
public IntPtr szExplainText;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public uint[] DataBuffer;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PDH_COUNTER_INFO_A
Public dwLength As UInteger
Public dwType As UInteger
Public CVersion As UInteger
Public CStatus As UInteger
Public lScale As Integer
Public lDefaultScale As Integer
Public dwUserData As UIntPtr
Public dwQueryUserData As UIntPtr
Public szFullPath As IntPtr
Public Anonymous As _Anonymous_e__Union
Public szExplainText As IntPtr
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public DataBuffer() As UInteger
End Structureimport ctypes
from ctypes import wintypes
class PDH_COUNTER_INFO_A(ctypes.Structure):
_fields_ = [
("dwLength", wintypes.DWORD),
("dwType", wintypes.DWORD),
("CVersion", wintypes.DWORD),
("CStatus", wintypes.DWORD),
("lScale", ctypes.c_int),
("lDefaultScale", ctypes.c_int),
("dwUserData", ctypes.c_size_t),
("dwQueryUserData", ctypes.c_size_t),
("szFullPath", ctypes.c_void_p),
("Anonymous", _Anonymous_e__Union),
("szExplainText", ctypes.c_void_p),
("DataBuffer", wintypes.DWORD * 1),
]#[repr(C)]
pub struct PDH_COUNTER_INFO_A {
pub dwLength: u32,
pub dwType: u32,
pub CVersion: u32,
pub CStatus: u32,
pub lScale: i32,
pub lDefaultScale: i32,
pub dwUserData: usize,
pub dwQueryUserData: usize,
pub szFullPath: *mut core::ffi::c_void,
pub Anonymous: _Anonymous_e__Union,
pub szExplainText: *mut core::ffi::c_void,
pub DataBuffer: [u32; 1],
}import "golang.org/x/sys/windows"
type PDH_COUNTER_INFO_A struct {
dwLength uint32
dwType uint32
CVersion uint32
CStatus uint32
lScale int32
lDefaultScale int32
dwUserData uintptr
dwQueryUserData uintptr
szFullPath uintptr
Anonymous _Anonymous_e__Union
szExplainText uintptr
DataBuffer [1]uint32
}type
PDH_COUNTER_INFO_A = record
dwLength: DWORD;
dwType: DWORD;
CVersion: DWORD;
CStatus: DWORD;
lScale: Integer;
lDefaultScale: Integer;
dwUserData: NativeUInt;
dwQueryUserData: NativeUInt;
szFullPath: Pointer;
Anonymous: _Anonymous_e__Union;
szExplainText: Pointer;
DataBuffer: array[0..0] of DWORD;
end;const PDH_COUNTER_INFO_A = extern struct {
dwLength: u32,
dwType: u32,
CVersion: u32,
CStatus: u32,
lScale: i32,
lDefaultScale: i32,
dwUserData: usize,
dwQueryUserData: usize,
szFullPath: ?*anyopaque,
Anonymous: _Anonymous_e__Union,
szExplainText: ?*anyopaque,
DataBuffer: [1]u32,
};type
PDH_COUNTER_INFO_A {.bycopy.} = object
dwLength: uint32
dwType: uint32
CVersion: uint32
CStatus: uint32
lScale: int32
lDefaultScale: int32
dwUserData: uint
dwQueryUserData: uint
szFullPath: pointer
Anonymous: _Anonymous_e__Union
szExplainText: pointer
DataBuffer: array[1, uint32]struct PDH_COUNTER_INFO_A
{
uint dwLength;
uint dwType;
uint CVersion;
uint CStatus;
int lScale;
int lDefaultScale;
size_t dwUserData;
size_t dwQueryUserData;
void* szFullPath;
_Anonymous_e__Union Anonymous;
void* szExplainText;
uint[1] DataBuffer;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PDH_COUNTER_INFO_A サイズ: 72 バイト(x86)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; dwLength : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwType : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; CVersion : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; CStatus : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lScale : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; lDefaultScale : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwUserData : UINT_PTR (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; dwQueryUserData : UINT_PTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; szFullPath : LPSTR (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+36, 28byte) varptr(st)+36 を基点に操作(28byte:入れ子/配列)
; szExplainText : LPSTR (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; DataBuffer : DWORD (+68, 4byte) varptr(st)+68 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PDH_COUNTER_INFO_A サイズ: 112 バイト(x64)
dim st, 28 ; 4byte整数×28(構造体サイズ 112 / 4 切り上げ)
; dwLength : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwType : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; CVersion : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; CStatus : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lScale : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; lDefaultScale : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwUserData : UINT_PTR (+24, 8byte) qpoke st,24,値 / qpeek(st,24) ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; dwQueryUserData : UINT_PTR (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; szFullPath : LPSTR (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; Anonymous : _Anonymous_e__Union (+48, 48byte) varptr(st)+48 を基点に操作(48byte:入れ子/配列)
; szExplainText : LPSTR (+96, 8byte) qpoke st,96,値 / qpeek(st,96) ※IronHSPのみ。3.7/3.8は lpoke st,96,下位 : lpoke st,100,上位
; DataBuffer : DWORD (+104, 4byte) varptr(st)+104 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PDH_COUNTER_INFO_A
#field int dwLength
#field int dwType
#field int CVersion
#field int CStatus
#field int lScale
#field int lDefaultScale
#field intptr dwUserData
#field intptr dwQueryUserData
#field intptr szFullPath
#field byte Anonymous 48
#field intptr szExplainText
#field int DataBuffer 1
#endstruct
stdim st, PDH_COUNTER_INFO_A ; NSTRUCT 変数を確保
st->dwLength = 100
mes "dwLength=" + st->dwLength
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。