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

PdhBrowseCountersW

関数
カウンター選択ダイアログを表示してカウンターを参照させる。
DLLpdh.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD PdhBrowseCountersW(
    PDH_BROWSE_DLG_CONFIG_W* pBrowseDlgData
);

パラメーター

名前方向
pBrowseDlgDataPDH_BROWSE_DLG_CONFIG_W*in

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PdhBrowseCountersW(
    PDH_BROWSE_DLG_CONFIG_W* pBrowseDlgData
);
[DllImport("pdh.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint PdhBrowseCountersW(
    IntPtr pBrowseDlgData   // PDH_BROWSE_DLG_CONFIG_W*
);
<DllImport("pdh.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PdhBrowseCountersW(
    pBrowseDlgData As IntPtr   ' PDH_BROWSE_DLG_CONFIG_W*
) As UInteger
End Function
' pBrowseDlgData : PDH_BROWSE_DLG_CONFIG_W*
Declare PtrSafe Function PdhBrowseCountersW Lib "pdh" ( _
    ByVal pBrowseDlgData 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

PdhBrowseCountersW = ctypes.windll.pdh.PdhBrowseCountersW
PdhBrowseCountersW.restype = wintypes.DWORD
PdhBrowseCountersW.argtypes = [
    ctypes.c_void_p,  # pBrowseDlgData : PDH_BROWSE_DLG_CONFIG_W*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	pdh = windows.NewLazySystemDLL("pdh.dll")
	procPdhBrowseCountersW = pdh.NewProc("PdhBrowseCountersW")
)

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