ホーム › System.Performance › PdhGetCounterInfoW
PdhGetCounterInfoW
関数カウンターの構成情報と説明文を取得する。
シグネチャ
// pdh.dll (Unicode / -W)
#include <windows.h>
DWORD PdhGetCounterInfoW(
PDH_HCOUNTER hCounter,
BOOLEAN bRetrieveExplainText,
DWORD* pdwBufferSize,
PDH_COUNTER_INFO_W* lpBuffer // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hCounter | PDH_HCOUNTER | in |
| bRetrieveExplainText | BOOLEAN | in |
| pdwBufferSize | DWORD* | inout |
| lpBuffer | PDH_COUNTER_INFO_W* | outoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// pdh.dll (Unicode / -W)
#include <windows.h>
DWORD PdhGetCounterInfoW(
PDH_HCOUNTER hCounter,
BOOLEAN bRetrieveExplainText,
DWORD* pdwBufferSize,
PDH_COUNTER_INFO_W* lpBuffer // optional
);[DllImport("pdh.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint PdhGetCounterInfoW(
IntPtr hCounter, // PDH_HCOUNTER
[MarshalAs(UnmanagedType.U1)] bool bRetrieveExplainText, // BOOLEAN
ref uint pdwBufferSize, // DWORD* in/out
IntPtr lpBuffer // PDH_COUNTER_INFO_W* optional, out
);<DllImport("pdh.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PdhGetCounterInfoW(
hCounter As IntPtr, ' PDH_HCOUNTER
<MarshalAs(UnmanagedType.U1)> bRetrieveExplainText As Boolean, ' BOOLEAN
ByRef pdwBufferSize As UInteger, ' DWORD* in/out
lpBuffer As IntPtr ' PDH_COUNTER_INFO_W* optional, out
) As UInteger
End Function' hCounter : PDH_HCOUNTER
' bRetrieveExplainText : BOOLEAN
' pdwBufferSize : DWORD* in/out
' lpBuffer : PDH_COUNTER_INFO_W* optional, out
Declare PtrSafe Function PdhGetCounterInfoW Lib "pdh" ( _
ByVal hCounter As LongPtr, _
ByVal bRetrieveExplainText As Byte, _
ByRef pdwBufferSize As Long, _
ByVal lpBuffer As LongPtr) 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
PdhGetCounterInfoW = ctypes.windll.pdh.PdhGetCounterInfoW
PdhGetCounterInfoW.restype = wintypes.DWORD
PdhGetCounterInfoW.argtypes = [
wintypes.HANDLE, # hCounter : PDH_HCOUNTER
ctypes.c_byte, # bRetrieveExplainText : BOOLEAN
ctypes.POINTER(wintypes.DWORD), # pdwBufferSize : DWORD* in/out
ctypes.c_void_p, # lpBuffer : PDH_COUNTER_INFO_W* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('pdh.dll')
PdhGetCounterInfoW = Fiddle::Function.new(
lib['PdhGetCounterInfoW'],
[
Fiddle::TYPE_VOIDP, # hCounter : PDH_HCOUNTER
Fiddle::TYPE_CHAR, # bRetrieveExplainText : BOOLEAN
Fiddle::TYPE_VOIDP, # pdwBufferSize : DWORD* in/out
Fiddle::TYPE_VOIDP, # lpBuffer : PDH_COUNTER_INFO_W* optional, out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "pdh")]
extern "system" {
fn PdhGetCounterInfoW(
hCounter: *mut core::ffi::c_void, // PDH_HCOUNTER
bRetrieveExplainText: u8, // BOOLEAN
pdwBufferSize: *mut u32, // DWORD* in/out
lpBuffer: *mut PDH_COUNTER_INFO_W // PDH_COUNTER_INFO_W* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("pdh.dll", CharSet = CharSet.Unicode)]
public static extern uint PdhGetCounterInfoW(IntPtr hCounter, [MarshalAs(UnmanagedType.U1)] bool bRetrieveExplainText, ref uint pdwBufferSize, IntPtr lpBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhGetCounterInfoW' -Namespace Win32 -PassThru
# $api::PdhGetCounterInfoW(hCounter, bRetrieveExplainText, pdwBufferSize, lpBuffer)#uselib "pdh.dll"
#func global PdhGetCounterInfoW "PdhGetCounterInfoW" wptr, wptr, wptr, wptr
; PdhGetCounterInfoW hCounter, bRetrieveExplainText, varptr(pdwBufferSize), varptr(lpBuffer) ; 戻り値は stat
; hCounter : PDH_HCOUNTER -> "wptr"
; bRetrieveExplainText : BOOLEAN -> "wptr"
; pdwBufferSize : DWORD* in/out -> "wptr"
; lpBuffer : PDH_COUNTER_INFO_W* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "pdh.dll" #cfunc global PdhGetCounterInfoW "PdhGetCounterInfoW" sptr, int, var, var ; res = PdhGetCounterInfoW(hCounter, bRetrieveExplainText, pdwBufferSize, lpBuffer) ; hCounter : PDH_HCOUNTER -> "sptr" ; bRetrieveExplainText : BOOLEAN -> "int" ; pdwBufferSize : DWORD* in/out -> "var" ; lpBuffer : PDH_COUNTER_INFO_W* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "pdh.dll" #cfunc global PdhGetCounterInfoW "PdhGetCounterInfoW" sptr, int, sptr, sptr ; res = PdhGetCounterInfoW(hCounter, bRetrieveExplainText, varptr(pdwBufferSize), varptr(lpBuffer)) ; hCounter : PDH_HCOUNTER -> "sptr" ; bRetrieveExplainText : BOOLEAN -> "int" ; pdwBufferSize : DWORD* in/out -> "sptr" ; lpBuffer : PDH_COUNTER_INFO_W* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD PdhGetCounterInfoW(PDH_HCOUNTER hCounter, BOOLEAN bRetrieveExplainText, DWORD* pdwBufferSize, PDH_COUNTER_INFO_W* lpBuffer) #uselib "pdh.dll" #cfunc global PdhGetCounterInfoW "PdhGetCounterInfoW" intptr, int, var, var ; res = PdhGetCounterInfoW(hCounter, bRetrieveExplainText, pdwBufferSize, lpBuffer) ; hCounter : PDH_HCOUNTER -> "intptr" ; bRetrieveExplainText : BOOLEAN -> "int" ; pdwBufferSize : DWORD* in/out -> "var" ; lpBuffer : PDH_COUNTER_INFO_W* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PdhGetCounterInfoW(PDH_HCOUNTER hCounter, BOOLEAN bRetrieveExplainText, DWORD* pdwBufferSize, PDH_COUNTER_INFO_W* lpBuffer) #uselib "pdh.dll" #cfunc global PdhGetCounterInfoW "PdhGetCounterInfoW" intptr, int, intptr, intptr ; res = PdhGetCounterInfoW(hCounter, bRetrieveExplainText, varptr(pdwBufferSize), varptr(lpBuffer)) ; hCounter : PDH_HCOUNTER -> "intptr" ; bRetrieveExplainText : BOOLEAN -> "int" ; pdwBufferSize : DWORD* in/out -> "intptr" ; lpBuffer : PDH_COUNTER_INFO_W* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
pdh = windows.NewLazySystemDLL("pdh.dll")
procPdhGetCounterInfoW = pdh.NewProc("PdhGetCounterInfoW")
)
// hCounter (PDH_HCOUNTER), bRetrieveExplainText (BOOLEAN), pdwBufferSize (DWORD* in/out), lpBuffer (PDH_COUNTER_INFO_W* optional, out)
r1, _, err := procPdhGetCounterInfoW.Call(
uintptr(hCounter),
uintptr(bRetrieveExplainText),
uintptr(pdwBufferSize),
uintptr(lpBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PdhGetCounterInfoW(
hCounter: THandle; // PDH_HCOUNTER
bRetrieveExplainText: ByteBool; // BOOLEAN
pdwBufferSize: Pointer; // DWORD* in/out
lpBuffer: Pointer // PDH_COUNTER_INFO_W* optional, out
): DWORD; stdcall;
external 'pdh.dll' name 'PdhGetCounterInfoW';result := DllCall("pdh\PdhGetCounterInfoW"
, "Ptr", hCounter ; PDH_HCOUNTER
, "Char", bRetrieveExplainText ; BOOLEAN
, "Ptr", pdwBufferSize ; DWORD* in/out
, "Ptr", lpBuffer ; PDH_COUNTER_INFO_W* optional, out
, "UInt") ; return: DWORD●PdhGetCounterInfoW(hCounter, bRetrieveExplainText, pdwBufferSize, lpBuffer) = DLL("pdh.dll", "dword PdhGetCounterInfoW(void*, byte, void*, void*)")
# 呼び出し: PdhGetCounterInfoW(hCounter, bRetrieveExplainText, pdwBufferSize, lpBuffer)
# hCounter : PDH_HCOUNTER -> "void*"
# bRetrieveExplainText : BOOLEAN -> "byte"
# pdwBufferSize : DWORD* in/out -> "void*"
# lpBuffer : PDH_COUNTER_INFO_W* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。