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

PDH_RAW_COUNTER_ITEM_W

構造体
サイズx64: 48 バイト / x86: 48 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
szNameLPWSTR8/4+0+0インスタンス名を表すワイド文字列である。
RawValuePDH_RAW_COUNTER40+8+8対応するインスタンスの生カウンタ値(PDH_RAW_COUNTER)である。

各言語での定義

#include <windows.h>

// FILETIME  (x64 8 / x86 8 バイト)
typedef struct FILETIME {
    DWORD dwLowDateTime;
    DWORD dwHighDateTime;
} FILETIME;

// PDH_RAW_COUNTER  (x64 40 / x86 40 バイト)
typedef struct PDH_RAW_COUNTER {
    DWORD CStatus;
    FILETIME TimeStamp;
    LONGLONG FirstValue;
    LONGLONG SecondValue;
    DWORD MultiCount;
} PDH_RAW_COUNTER;

// PDH_RAW_COUNTER_ITEM_W  (x64 48 / x86 48 バイト)
typedef struct PDH_RAW_COUNTER_ITEM_W {
    LPWSTR szName;
    PDH_RAW_COUNTER RawValue;
} PDH_RAW_COUNTER_ITEM_W;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FILETIME
{
    public uint dwLowDateTime;
    public uint dwHighDateTime;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PDH_RAW_COUNTER
{
    public uint CStatus;
    public FILETIME TimeStamp;
    public long FirstValue;
    public long SecondValue;
    public uint MultiCount;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PDH_RAW_COUNTER_ITEM_W
{
    public IntPtr szName;
    public PDH_RAW_COUNTER RawValue;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FILETIME
    Public dwLowDateTime As UInteger
    Public dwHighDateTime As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PDH_RAW_COUNTER
    Public CStatus As UInteger
    Public TimeStamp As FILETIME
    Public FirstValue As Long
    Public SecondValue As Long
    Public MultiCount As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PDH_RAW_COUNTER_ITEM_W
    Public szName As IntPtr
    Public RawValue As PDH_RAW_COUNTER
End Structure
import ctypes
from ctypes import wintypes

class FILETIME(ctypes.Structure):
    _fields_ = [
        ("dwLowDateTime", wintypes.DWORD),
        ("dwHighDateTime", wintypes.DWORD),
    ]

class PDH_RAW_COUNTER(ctypes.Structure):
    _fields_ = [
        ("CStatus", wintypes.DWORD),
        ("TimeStamp", FILETIME),
        ("FirstValue", ctypes.c_longlong),
        ("SecondValue", ctypes.c_longlong),
        ("MultiCount", wintypes.DWORD),
    ]

class PDH_RAW_COUNTER_ITEM_W(ctypes.Structure):
    _fields_ = [
        ("szName", ctypes.c_void_p),
        ("RawValue", PDH_RAW_COUNTER),
    ]
#[repr(C)]
pub struct FILETIME {
    pub dwLowDateTime: u32,
    pub dwHighDateTime: u32,
}

#[repr(C)]
pub struct PDH_RAW_COUNTER {
    pub CStatus: u32,
    pub TimeStamp: FILETIME,
    pub FirstValue: i64,
    pub SecondValue: i64,
    pub MultiCount: u32,
}

#[repr(C)]
pub struct PDH_RAW_COUNTER_ITEM_W {
    pub szName: *mut core::ffi::c_void,
    pub RawValue: PDH_RAW_COUNTER,
}
import "golang.org/x/sys/windows"

type FILETIME struct {
	dwLowDateTime uint32
	dwHighDateTime uint32
}

type PDH_RAW_COUNTER struct {
	CStatus uint32
	TimeStamp FILETIME
	FirstValue int64
	SecondValue int64
	MultiCount uint32
}

type PDH_RAW_COUNTER_ITEM_W struct {
	szName uintptr
	RawValue PDH_RAW_COUNTER
}
type
  FILETIME = record
    dwLowDateTime: DWORD;
    dwHighDateTime: DWORD;
  end;

  PDH_RAW_COUNTER = record
    CStatus: DWORD;
    TimeStamp: FILETIME;
    FirstValue: Int64;
    SecondValue: Int64;
    MultiCount: DWORD;
  end;

  PDH_RAW_COUNTER_ITEM_W = record
    szName: Pointer;
    RawValue: PDH_RAW_COUNTER;
  end;
const FILETIME = extern struct {
    dwLowDateTime: u32,
    dwHighDateTime: u32,
};

const PDH_RAW_COUNTER = extern struct {
    CStatus: u32,
    TimeStamp: FILETIME,
    FirstValue: i64,
    SecondValue: i64,
    MultiCount: u32,
};

const PDH_RAW_COUNTER_ITEM_W = extern struct {
    szName: ?*anyopaque,
    RawValue: PDH_RAW_COUNTER,
};
type
  FILETIME {.bycopy.} = object
    dwLowDateTime: uint32
    dwHighDateTime: uint32

  PDH_RAW_COUNTER {.bycopy.} = object
    CStatus: uint32
    TimeStamp: FILETIME
    FirstValue: int64
    SecondValue: int64
    MultiCount: uint32

  PDH_RAW_COUNTER_ITEM_W {.bycopy.} = object
    szName: pointer
    RawValue: PDH_RAW_COUNTER
struct FILETIME
{
    uint dwLowDateTime;
    uint dwHighDateTime;
}

struct PDH_RAW_COUNTER
{
    uint CStatus;
    FILETIME TimeStamp;
    long FirstValue;
    long SecondValue;
    uint MultiCount;
}

struct PDH_RAW_COUNTER_ITEM_W
{
    void* szName;
    PDH_RAW_COUNTER RawValue;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; PDH_RAW_COUNTER_ITEM_W サイズ: 48 バイト(x86)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; szName : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; RawValue : PDH_RAW_COUNTER (+8, 40byte)  varptr(st)+8 を基点に操作(40byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PDH_RAW_COUNTER_ITEM_W サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; szName : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; RawValue : PDH_RAW_COUNTER (+8, 40byte)  varptr(st)+8 を基点に操作(40byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global FILETIME
    #field int dwLowDateTime
    #field int dwHighDateTime
#endstruct

#defstruct global PDH_RAW_COUNTER
    #field int CStatus
    #field FILETIME TimeStamp
    #field int64 FirstValue
    #field int64 SecondValue
    #field int MultiCount
#endstruct

#defstruct global PDH_RAW_COUNTER_ITEM_W
    #field intptr szName
    #field PDH_RAW_COUNTER RawValue
#endstruct

stdim st, PDH_RAW_COUNTER_ITEM_W        ; NSTRUCT 変数を確保