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

PdhExpandWildCardPathHW

関数
ハンドル指定でワイルドカードパスを展開する。
DLLpdh.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD PdhExpandWildCardPathHW(
    PDH_HLOG hDataSource,   // optional
    LPCWSTR szWildCardPath,
    LPWSTR mszExpandedPathList,   // optional
    DWORD* pcchPathListLength,
    DWORD dwFlags
);

パラメーター

名前方向
hDataSourcePDH_HLOGinoptional
szWildCardPathLPCWSTRin
mszExpandedPathListLPWSTRoutoptional
pcchPathListLengthDWORD*inout
dwFlagsDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PdhExpandWildCardPathHW(
    PDH_HLOG hDataSource,   // optional
    LPCWSTR szWildCardPath,
    LPWSTR mszExpandedPathList,   // optional
    DWORD* pcchPathListLength,
    DWORD dwFlags
);
[DllImport("pdh.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint PdhExpandWildCardPathHW(
    IntPtr hDataSource,   // PDH_HLOG optional
    [MarshalAs(UnmanagedType.LPWStr)] string szWildCardPath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder mszExpandedPathList,   // LPWSTR optional, out
    ref uint pcchPathListLength,   // DWORD* in/out
    uint dwFlags   // DWORD
);
<DllImport("pdh.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PdhExpandWildCardPathHW(
    hDataSource As IntPtr,   ' PDH_HLOG optional
    <MarshalAs(UnmanagedType.LPWStr)> szWildCardPath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> mszExpandedPathList As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef pcchPathListLength As UInteger,   ' DWORD* in/out
    dwFlags As UInteger   ' DWORD
) As UInteger
End Function
' hDataSource : PDH_HLOG optional
' szWildCardPath : LPCWSTR
' mszExpandedPathList : LPWSTR optional, out
' pcchPathListLength : DWORD* in/out
' dwFlags : DWORD
Declare PtrSafe Function PdhExpandWildCardPathHW Lib "pdh" ( _
    ByVal hDataSource As LongPtr, _
    ByVal szWildCardPath As LongPtr, _
    ByVal mszExpandedPathList As LongPtr, _
    ByRef pcchPathListLength 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

PdhExpandWildCardPathHW = ctypes.windll.pdh.PdhExpandWildCardPathHW
PdhExpandWildCardPathHW.restype = wintypes.DWORD
PdhExpandWildCardPathHW.argtypes = [
    wintypes.HANDLE,  # hDataSource : PDH_HLOG optional
    wintypes.LPCWSTR,  # szWildCardPath : LPCWSTR
    wintypes.LPWSTR,  # mszExpandedPathList : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchPathListLength : DWORD* in/out
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('pdh.dll')
PdhExpandWildCardPathHW = Fiddle::Function.new(
  lib['PdhExpandWildCardPathHW'],
  [
    Fiddle::TYPE_VOIDP,  # hDataSource : PDH_HLOG optional
    Fiddle::TYPE_VOIDP,  # szWildCardPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # mszExpandedPathList : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchPathListLength : 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 PdhExpandWildCardPathHW(
        hDataSource: *mut core::ffi::c_void,  // PDH_HLOG optional
        szWildCardPath: *const u16,  // LPCWSTR
        mszExpandedPathList: *mut u16,  // LPWSTR optional, out
        pcchPathListLength: *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 PdhExpandWildCardPathHW(IntPtr hDataSource, [MarshalAs(UnmanagedType.LPWStr)] string szWildCardPath, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder mszExpandedPathList, ref uint pcchPathListLength, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhExpandWildCardPathHW' -Namespace Win32 -PassThru
# $api::PdhExpandWildCardPathHW(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
#uselib "pdh.dll"
#func global PdhExpandWildCardPathHW "PdhExpandWildCardPathHW" wptr, wptr, wptr, wptr, wptr
; PdhExpandWildCardPathHW hDataSource, szWildCardPath, varptr(mszExpandedPathList), varptr(pcchPathListLength), dwFlags   ; 戻り値は stat
; hDataSource : PDH_HLOG optional -> "wptr"
; szWildCardPath : LPCWSTR -> "wptr"
; mszExpandedPathList : LPWSTR optional, out -> "wptr"
; pcchPathListLength : DWORD* in/out -> "wptr"
; dwFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "pdh.dll"
#cfunc global PdhExpandWildCardPathHW "PdhExpandWildCardPathHW" sptr, wstr, var, var, int
; res = PdhExpandWildCardPathHW(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
; hDataSource : PDH_HLOG optional -> "sptr"
; szWildCardPath : LPCWSTR -> "wstr"
; mszExpandedPathList : LPWSTR optional, out -> "var"
; pcchPathListLength : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PdhExpandWildCardPathHW(PDH_HLOG hDataSource, LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, DWORD* pcchPathListLength, DWORD dwFlags)
#uselib "pdh.dll"
#cfunc global PdhExpandWildCardPathHW "PdhExpandWildCardPathHW" intptr, wstr, var, var, int
; res = PdhExpandWildCardPathHW(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
; hDataSource : PDH_HLOG optional -> "intptr"
; szWildCardPath : LPCWSTR -> "wstr"
; mszExpandedPathList : LPWSTR optional, out -> "var"
; pcchPathListLength : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	pdh = windows.NewLazySystemDLL("pdh.dll")
	procPdhExpandWildCardPathHW = pdh.NewProc("PdhExpandWildCardPathHW")
)

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