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

PDH_COUNTER_PATH_ELEMENTS_W

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

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

フィールド

フィールドサイズx64x86説明
szMachineNameLPWSTR8/4+0+0マシン名(ワイド)である。ローカルはNULL可。
szObjectNameLPWSTR8/4+8+4パフォーマンスオブジェクト名(ワイド)である。
szInstanceNameLPWSTR8/4+16+8インスタンス名(ワイド)である。インスタンス無しはNULL可。
szParentInstanceLPWSTR8/4+24+12親インスタンス名(ワイド)である。無ければNULL可。
dwInstanceIndexDWORD4+32+16同名インスタンスを区別するインデックスである。
szCounterNameLPWSTR8/4+40+20カウンタ名(ワイド)である。

各言語での定義

#include <windows.h>

// PDH_COUNTER_PATH_ELEMENTS_W  (x64 48 / x86 24 バイト)
typedef struct PDH_COUNTER_PATH_ELEMENTS_W {
    LPWSTR szMachineName;
    LPWSTR szObjectName;
    LPWSTR szInstanceName;
    LPWSTR szParentInstance;
    DWORD dwInstanceIndex;
    LPWSTR szCounterName;
} PDH_COUNTER_PATH_ELEMENTS_W;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PDH_COUNTER_PATH_ELEMENTS_W
{
    public IntPtr szMachineName;
    public IntPtr szObjectName;
    public IntPtr szInstanceName;
    public IntPtr szParentInstance;
    public uint dwInstanceIndex;
    public IntPtr szCounterName;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PDH_COUNTER_PATH_ELEMENTS_W
    Public szMachineName As IntPtr
    Public szObjectName As IntPtr
    Public szInstanceName As IntPtr
    Public szParentInstance As IntPtr
    Public dwInstanceIndex As UInteger
    Public szCounterName As IntPtr
End Structure
import ctypes
from ctypes import wintypes

class PDH_COUNTER_PATH_ELEMENTS_W(ctypes.Structure):
    _fields_ = [
        ("szMachineName", ctypes.c_void_p),
        ("szObjectName", ctypes.c_void_p),
        ("szInstanceName", ctypes.c_void_p),
        ("szParentInstance", ctypes.c_void_p),
        ("dwInstanceIndex", wintypes.DWORD),
        ("szCounterName", ctypes.c_void_p),
    ]
#[repr(C)]
pub struct PDH_COUNTER_PATH_ELEMENTS_W {
    pub szMachineName: *mut core::ffi::c_void,
    pub szObjectName: *mut core::ffi::c_void,
    pub szInstanceName: *mut core::ffi::c_void,
    pub szParentInstance: *mut core::ffi::c_void,
    pub dwInstanceIndex: u32,
    pub szCounterName: *mut core::ffi::c_void,
}
import "golang.org/x/sys/windows"

type PDH_COUNTER_PATH_ELEMENTS_W struct {
	szMachineName uintptr
	szObjectName uintptr
	szInstanceName uintptr
	szParentInstance uintptr
	dwInstanceIndex uint32
	szCounterName uintptr
}
type
  PDH_COUNTER_PATH_ELEMENTS_W = record
    szMachineName: Pointer;
    szObjectName: Pointer;
    szInstanceName: Pointer;
    szParentInstance: Pointer;
    dwInstanceIndex: DWORD;
    szCounterName: Pointer;
  end;
const PDH_COUNTER_PATH_ELEMENTS_W = extern struct {
    szMachineName: ?*anyopaque,
    szObjectName: ?*anyopaque,
    szInstanceName: ?*anyopaque,
    szParentInstance: ?*anyopaque,
    dwInstanceIndex: u32,
    szCounterName: ?*anyopaque,
};
type
  PDH_COUNTER_PATH_ELEMENTS_W {.bycopy.} = object
    szMachineName: pointer
    szObjectName: pointer
    szInstanceName: pointer
    szParentInstance: pointer
    dwInstanceIndex: uint32
    szCounterName: pointer
struct PDH_COUNTER_PATH_ELEMENTS_W
{
    void* szMachineName;
    void* szObjectName;
    void* szInstanceName;
    void* szParentInstance;
    uint dwInstanceIndex;
    void* szCounterName;
}

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_PATH_ELEMENTS_W サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; szMachineName : LPWSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; szObjectName : LPWSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; szInstanceName : LPWSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; szParentInstance : LPWSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwInstanceIndex : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; szCounterName : LPWSTR (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; PDH_COUNTER_PATH_ELEMENTS_W サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; szMachineName : LPWSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; szObjectName : LPWSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; szInstanceName : LPWSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; szParentInstance : LPWSTR (+24, 8byte)  qpoke st,24,値 / qpeek(st,24)  ※IronHSPのみ。3.7/3.8は lpoke st,24,下位 : lpoke st,28,上位
; dwInstanceIndex : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; szCounterName : LPWSTR (+40, 8byte)  qpoke st,40,値 / qpeek(st,40)  ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global PDH_COUNTER_PATH_ELEMENTS_W
    #field intptr szMachineName
    #field intptr szObjectName
    #field intptr szInstanceName
    #field intptr szParentInstance
    #field int dwInstanceIndex
    #field intptr szCounterName
#endstruct

stdim st, PDH_COUNTER_PATH_ELEMENTS_W        ; NSTRUCT 変数を確保
st->dwInstanceIndex = 100
mes "dwInstanceIndex=" + st->dwInstanceIndex