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

PdhParseCounterPathW

関数
カウンターパス文字列を構成要素に分解して解析する。
DLLpdh.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// pdh.dll  (Unicode / -W)
#include <windows.h>

DWORD PdhParseCounterPathW(
    LPCWSTR szFullPathBuffer,
    PDH_COUNTER_PATH_ELEMENTS_W* pCounterPathElements,   // optional
    DWORD* pdwBufferSize,
    DWORD dwFlags
);

パラメーター

名前方向
szFullPathBufferLPCWSTRin
pCounterPathElementsPDH_COUNTER_PATH_ELEMENTS_W*outoptional
pdwBufferSizeDWORD*inout
dwFlagsDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

// pdh.dll  (Unicode / -W)
#include <windows.h>

DWORD PdhParseCounterPathW(
    LPCWSTR szFullPathBuffer,
    PDH_COUNTER_PATH_ELEMENTS_W* pCounterPathElements,   // optional
    DWORD* pdwBufferSize,
    DWORD dwFlags
);
[DllImport("pdh.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint PdhParseCounterPathW(
    [MarshalAs(UnmanagedType.LPWStr)] string szFullPathBuffer,   // LPCWSTR
    IntPtr pCounterPathElements,   // PDH_COUNTER_PATH_ELEMENTS_W* optional, out
    ref uint pdwBufferSize,   // DWORD* in/out
    uint dwFlags   // DWORD
);
<DllImport("pdh.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PdhParseCounterPathW(
    <MarshalAs(UnmanagedType.LPWStr)> szFullPathBuffer As String,   ' LPCWSTR
    pCounterPathElements As IntPtr,   ' PDH_COUNTER_PATH_ELEMENTS_W* optional, out
    ByRef pdwBufferSize As UInteger,   ' DWORD* in/out
    dwFlags As UInteger   ' DWORD
) As UInteger
End Function
' szFullPathBuffer : LPCWSTR
' pCounterPathElements : PDH_COUNTER_PATH_ELEMENTS_W* optional, out
' pdwBufferSize : DWORD* in/out
' dwFlags : DWORD
Declare PtrSafe Function PdhParseCounterPathW Lib "pdh" ( _
    ByVal szFullPathBuffer As LongPtr, _
    ByVal pCounterPathElements As LongPtr, _
    ByRef pdwBufferSize As Long, _
    ByVal dwFlags As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PdhParseCounterPathW = ctypes.windll.pdh.PdhParseCounterPathW
PdhParseCounterPathW.restype = wintypes.DWORD
PdhParseCounterPathW.argtypes = [
    wintypes.LPCWSTR,  # szFullPathBuffer : LPCWSTR
    ctypes.c_void_p,  # pCounterPathElements : PDH_COUNTER_PATH_ELEMENTS_W* optional, out
    ctypes.POINTER(wintypes.DWORD),  # pdwBufferSize : DWORD* in/out
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('pdh.dll')
PdhParseCounterPathW = Fiddle::Function.new(
  lib['PdhParseCounterPathW'],
  [
    Fiddle::TYPE_VOIDP,  # szFullPathBuffer : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pCounterPathElements : PDH_COUNTER_PATH_ELEMENTS_W* optional, out
    Fiddle::TYPE_VOIDP,  # pdwBufferSize : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "pdh")]
extern "system" {
    fn PdhParseCounterPathW(
        szFullPathBuffer: *const u16,  // LPCWSTR
        pCounterPathElements: *mut PDH_COUNTER_PATH_ELEMENTS_W,  // PDH_COUNTER_PATH_ELEMENTS_W* optional, out
        pdwBufferSize: *mut u32,  // DWORD* in/out
        dwFlags: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("pdh.dll", CharSet = CharSet.Unicode)]
public static extern uint PdhParseCounterPathW([MarshalAs(UnmanagedType.LPWStr)] string szFullPathBuffer, IntPtr pCounterPathElements, ref uint pdwBufferSize, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhParseCounterPathW' -Namespace Win32 -PassThru
# $api::PdhParseCounterPathW(szFullPathBuffer, pCounterPathElements, pdwBufferSize, dwFlags)
#uselib "pdh.dll"
#func global PdhParseCounterPathW "PdhParseCounterPathW" wptr, wptr, wptr, wptr
; PdhParseCounterPathW szFullPathBuffer, varptr(pCounterPathElements), varptr(pdwBufferSize), dwFlags   ; 戻り値は stat
; szFullPathBuffer : LPCWSTR -> "wptr"
; pCounterPathElements : PDH_COUNTER_PATH_ELEMENTS_W* optional, out -> "wptr"
; pdwBufferSize : DWORD* in/out -> "wptr"
; dwFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "pdh.dll"
#cfunc global PdhParseCounterPathW "PdhParseCounterPathW" wstr, var, var, int
; res = PdhParseCounterPathW(szFullPathBuffer, pCounterPathElements, pdwBufferSize, dwFlags)
; szFullPathBuffer : LPCWSTR -> "wstr"
; pCounterPathElements : PDH_COUNTER_PATH_ELEMENTS_W* optional, out -> "var"
; pdwBufferSize : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PdhParseCounterPathW(LPCWSTR szFullPathBuffer, PDH_COUNTER_PATH_ELEMENTS_W* pCounterPathElements, DWORD* pdwBufferSize, DWORD dwFlags)
#uselib "pdh.dll"
#cfunc global PdhParseCounterPathW "PdhParseCounterPathW" wstr, var, var, int
; res = PdhParseCounterPathW(szFullPathBuffer, pCounterPathElements, pdwBufferSize, dwFlags)
; szFullPathBuffer : LPCWSTR -> "wstr"
; pCounterPathElements : PDH_COUNTER_PATH_ELEMENTS_W* optional, out -> "var"
; pdwBufferSize : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	pdh = windows.NewLazySystemDLL("pdh.dll")
	procPdhParseCounterPathW = pdh.NewProc("PdhParseCounterPathW")
)

// szFullPathBuffer (LPCWSTR), pCounterPathElements (PDH_COUNTER_PATH_ELEMENTS_W* optional, out), pdwBufferSize (DWORD* in/out), dwFlags (DWORD)
r1, _, err := procPdhParseCounterPathW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFullPathBuffer))),
	uintptr(pCounterPathElements),
	uintptr(pdwBufferSize),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PdhParseCounterPathW(
  szFullPathBuffer: PWideChar;   // LPCWSTR
  pCounterPathElements: Pointer;   // PDH_COUNTER_PATH_ELEMENTS_W* optional, out
  pdwBufferSize: Pointer;   // DWORD* in/out
  dwFlags: DWORD   // DWORD
): DWORD; stdcall;
  external 'pdh.dll' name 'PdhParseCounterPathW';
result := DllCall("pdh\PdhParseCounterPathW"
    , "WStr", szFullPathBuffer   ; LPCWSTR
    , "Ptr", pCounterPathElements   ; PDH_COUNTER_PATH_ELEMENTS_W* optional, out
    , "Ptr", pdwBufferSize   ; DWORD* in/out
    , "UInt", dwFlags   ; DWORD
    , "UInt")   ; return: DWORD
●PdhParseCounterPathW(szFullPathBuffer, pCounterPathElements, pdwBufferSize, dwFlags) = DLL("pdh.dll", "dword PdhParseCounterPathW(char*, void*, void*, dword)")
# 呼び出し: PdhParseCounterPathW(szFullPathBuffer, pCounterPathElements, pdwBufferSize, dwFlags)
# szFullPathBuffer : LPCWSTR -> "char*"
# pCounterPathElements : PDH_COUNTER_PATH_ELEMENTS_W* optional, out -> "void*"
# pdwBufferSize : DWORD* in/out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。