ホーム › System.Performance › PdhExpandCounterPathA
PdhExpandCounterPathA
関数ワイルドカードパスをパス一覧に展開する(ANSI版)。
シグネチャ
// pdh.dll (ANSI / -A)
#include <windows.h>
DWORD PdhExpandCounterPathA(
LPCSTR szWildCardPath,
LPSTR mszExpandedPathList, // optional
DWORD* pcchPathListLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szWildCardPath | LPCSTR | in |
| mszExpandedPathList | LPSTR | outoptional |
| pcchPathListLength | DWORD* | inout |
戻り値の型: DWORD
各言語での呼び出し定義
// pdh.dll (ANSI / -A)
#include <windows.h>
DWORD PdhExpandCounterPathA(
LPCSTR szWildCardPath,
LPSTR mszExpandedPathList, // optional
DWORD* pcchPathListLength
);[DllImport("pdh.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint PdhExpandCounterPathA(
[MarshalAs(UnmanagedType.LPStr)] string szWildCardPath, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder mszExpandedPathList, // LPSTR optional, out
ref uint pcchPathListLength // DWORD* in/out
);<DllImport("pdh.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PdhExpandCounterPathA(
<MarshalAs(UnmanagedType.LPStr)> szWildCardPath As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> mszExpandedPathList As System.Text.StringBuilder, ' LPSTR optional, out
ByRef pcchPathListLength As UInteger ' DWORD* in/out
) As UInteger
End Function' szWildCardPath : LPCSTR
' mszExpandedPathList : LPSTR optional, out
' pcchPathListLength : DWORD* in/out
Declare PtrSafe Function PdhExpandCounterPathA Lib "pdh" ( _
ByVal szWildCardPath As String, _
ByVal mszExpandedPathList As String, _
ByRef pcchPathListLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PdhExpandCounterPathA = ctypes.windll.pdh.PdhExpandCounterPathA
PdhExpandCounterPathA.restype = wintypes.DWORD
PdhExpandCounterPathA.argtypes = [
wintypes.LPCSTR, # szWildCardPath : LPCSTR
wintypes.LPSTR, # mszExpandedPathList : LPSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchPathListLength : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('pdh.dll')
PdhExpandCounterPathA = Fiddle::Function.new(
lib['PdhExpandCounterPathA'],
[
Fiddle::TYPE_VOIDP, # szWildCardPath : LPCSTR
Fiddle::TYPE_VOIDP, # mszExpandedPathList : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pcchPathListLength : DWORD* in/out
],
-Fiddle::TYPE_INT)#[link(name = "pdh")]
extern "system" {
fn PdhExpandCounterPathA(
szWildCardPath: *const u8, // LPCSTR
mszExpandedPathList: *mut u8, // LPSTR optional, out
pcchPathListLength: *mut u32 // DWORD* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("pdh.dll", CharSet = CharSet.Ansi)]
public static extern uint PdhExpandCounterPathA([MarshalAs(UnmanagedType.LPStr)] string szWildCardPath, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder mszExpandedPathList, ref uint pcchPathListLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhExpandCounterPathA' -Namespace Win32 -PassThru
# $api::PdhExpandCounterPathA(szWildCardPath, mszExpandedPathList, pcchPathListLength)#uselib "pdh.dll"
#func global PdhExpandCounterPathA "PdhExpandCounterPathA" sptr, sptr, sptr
; PdhExpandCounterPathA szWildCardPath, varptr(mszExpandedPathList), varptr(pcchPathListLength) ; 戻り値は stat
; szWildCardPath : LPCSTR -> "sptr"
; mszExpandedPathList : LPSTR optional, out -> "sptr"
; pcchPathListLength : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "pdh.dll" #cfunc global PdhExpandCounterPathA "PdhExpandCounterPathA" str, var, var ; res = PdhExpandCounterPathA(szWildCardPath, mszExpandedPathList, pcchPathListLength) ; szWildCardPath : LPCSTR -> "str" ; mszExpandedPathList : LPSTR optional, out -> "var" ; pcchPathListLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "pdh.dll" #cfunc global PdhExpandCounterPathA "PdhExpandCounterPathA" str, sptr, sptr ; res = PdhExpandCounterPathA(szWildCardPath, varptr(mszExpandedPathList), varptr(pcchPathListLength)) ; szWildCardPath : LPCSTR -> "str" ; mszExpandedPathList : LPSTR optional, out -> "sptr" ; pcchPathListLength : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD PdhExpandCounterPathA(LPCSTR szWildCardPath, LPSTR mszExpandedPathList, DWORD* pcchPathListLength) #uselib "pdh.dll" #cfunc global PdhExpandCounterPathA "PdhExpandCounterPathA" str, var, var ; res = PdhExpandCounterPathA(szWildCardPath, mszExpandedPathList, pcchPathListLength) ; szWildCardPath : LPCSTR -> "str" ; mszExpandedPathList : LPSTR optional, out -> "var" ; pcchPathListLength : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PdhExpandCounterPathA(LPCSTR szWildCardPath, LPSTR mszExpandedPathList, DWORD* pcchPathListLength) #uselib "pdh.dll" #cfunc global PdhExpandCounterPathA "PdhExpandCounterPathA" str, intptr, intptr ; res = PdhExpandCounterPathA(szWildCardPath, varptr(mszExpandedPathList), varptr(pcchPathListLength)) ; szWildCardPath : LPCSTR -> "str" ; mszExpandedPathList : LPSTR optional, out -> "intptr" ; pcchPathListLength : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
pdh = windows.NewLazySystemDLL("pdh.dll")
procPdhExpandCounterPathA = pdh.NewProc("PdhExpandCounterPathA")
)
// szWildCardPath (LPCSTR), mszExpandedPathList (LPSTR optional, out), pcchPathListLength (DWORD* in/out)
r1, _, err := procPdhExpandCounterPathA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szWildCardPath))),
uintptr(mszExpandedPathList),
uintptr(pcchPathListLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PdhExpandCounterPathA(
szWildCardPath: PAnsiChar; // LPCSTR
mszExpandedPathList: PAnsiChar; // LPSTR optional, out
pcchPathListLength: Pointer // DWORD* in/out
): DWORD; stdcall;
external 'pdh.dll' name 'PdhExpandCounterPathA';result := DllCall("pdh\PdhExpandCounterPathA"
, "AStr", szWildCardPath ; LPCSTR
, "Ptr", mszExpandedPathList ; LPSTR optional, out
, "Ptr", pcchPathListLength ; DWORD* in/out
, "UInt") ; return: DWORD●PdhExpandCounterPathA(szWildCardPath, mszExpandedPathList, pcchPathListLength) = DLL("pdh.dll", "dword PdhExpandCounterPathA(char*, char*, void*)")
# 呼び出し: PdhExpandCounterPathA(szWildCardPath, mszExpandedPathList, pcchPathListLength)
# szWildCardPath : LPCSTR -> "char*"
# mszExpandedPathList : LPSTR optional, out -> "char*"
# pcchPathListLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。