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

PDH_COUNTER_PATH_ELEMENTS_A

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

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

フィールド

フィールドサイズx64x86説明
szMachineNameLPSTR8/4+0+0コンピューター名を指定する、NULL で終わる文字列へのポインターです。
szObjectNameLPSTR8/4+8+4オブジェクト名を指定する、NULL で終わる文字列へのポインターです。
szInstanceNameLPSTR8/4+16+8インスタンス名を指定する、NULL で終わる文字列へのポインターです。ワイルドカード文字を含めることができます。
szParentInstanceLPSTR8/4+24+12親インスタンス名を指定する、NULL で終わる文字列へのポインターです。ワイルドカード文字を含めることができます。
dwInstanceIndexDWORD4+32+16重複するインスタンス名を一意に識別するために使用されるインデックスです。
szCounterNameLPSTR8/4+40+20カウンター名を指定する、NULL で終わる文字列へのポインターです。

公式ドキュメント

PDH_COUNTER_PATH_ELEMENTS 構造体は、カウンターパスの構成要素を格納します。

解説(Remarks)

この構造体は、カウンターパスを作成する PdhMakeCounterPath と、カウンターパスを解析する PdhParseCounterPath で使用されます。

この構造体のメモリを割り当てるときは、この構造体の末尾に付加される szCounterName などのメンバー文字列の分も含めて、十分なメモリを割り当ててください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

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

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PDH_COUNTER_PATH_ELEMENTS_A
{
    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_A
    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_A(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_A {
    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_A struct {
	szMachineName uintptr
	szObjectName uintptr
	szInstanceName uintptr
	szParentInstance uintptr
	dwInstanceIndex uint32
	szCounterName uintptr
}
type
  PDH_COUNTER_PATH_ELEMENTS_A = record
    szMachineName: Pointer;
    szObjectName: Pointer;
    szInstanceName: Pointer;
    szParentInstance: Pointer;
    dwInstanceIndex: DWORD;
    szCounterName: Pointer;
  end;
const PDH_COUNTER_PATH_ELEMENTS_A = extern struct {
    szMachineName: ?*anyopaque,
    szObjectName: ?*anyopaque,
    szInstanceName: ?*anyopaque,
    szParentInstance: ?*anyopaque,
    dwInstanceIndex: u32,
    szCounterName: ?*anyopaque,
};
type
  PDH_COUNTER_PATH_ELEMENTS_A {.bycopy.} = object
    szMachineName: pointer
    szObjectName: pointer
    szInstanceName: pointer
    szParentInstance: pointer
    dwInstanceIndex: uint32
    szCounterName: pointer
struct PDH_COUNTER_PATH_ELEMENTS_A
{
    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_A サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; szMachineName : LPSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; szObjectName : LPSTR (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; szInstanceName : LPSTR (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; szParentInstance : LPSTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwInstanceIndex : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; szCounterName : LPSTR (+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_A サイズ: 48 バイト(x64)
dim st, 12    ; 4byte整数×12(構造体サイズ 48 / 4 切り上げ)
; szMachineName : LPSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; szObjectName : LPSTR (+8, 8byte)  qpoke st,8,値 / qpeek(st,8)  ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; szInstanceName : LPSTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; szParentInstance : LPSTR (+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 : LPSTR (+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_A
    #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_A        ; NSTRUCT 変数を確保
st->dwInstanceIndex = 100
mes "dwInstanceIndex=" + st->dwInstanceIndex