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

PdhExpandWildCardPathHA

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

シグネチャ

// pdh.dll  (ANSI / -A)
#include <windows.h>

DWORD PdhExpandWildCardPathHA(
    PDH_HLOG hDataSource,   // optional
    LPCSTR szWildCardPath,
    LPSTR mszExpandedPathList,   // optional
    DWORD* pcchPathListLength,
    DWORD dwFlags
);

パラメーター

名前方向
hDataSourcePDH_HLOGinoptional
szWildCardPathLPCSTRin
mszExpandedPathListLPSTRoutoptional
pcchPathListLengthDWORD*inout
dwFlagsDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

// pdh.dll  (ANSI / -A)
#include <windows.h>

DWORD PdhExpandWildCardPathHA(
    PDH_HLOG hDataSource,   // optional
    LPCSTR szWildCardPath,
    LPSTR mszExpandedPathList,   // optional
    DWORD* pcchPathListLength,
    DWORD dwFlags
);
[DllImport("pdh.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint PdhExpandWildCardPathHA(
    IntPtr hDataSource,   // PDH_HLOG optional
    [MarshalAs(UnmanagedType.LPStr)] string szWildCardPath,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder mszExpandedPathList,   // LPSTR optional, out
    ref uint pcchPathListLength,   // DWORD* in/out
    uint dwFlags   // DWORD
);
<DllImport("pdh.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PdhExpandWildCardPathHA(
    hDataSource As IntPtr,   ' PDH_HLOG optional
    <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
    dwFlags As UInteger   ' DWORD
) As UInteger
End Function
' hDataSource : PDH_HLOG optional
' szWildCardPath : LPCSTR
' mszExpandedPathList : LPSTR optional, out
' pcchPathListLength : DWORD* in/out
' dwFlags : DWORD
Declare PtrSafe Function PdhExpandWildCardPathHA Lib "pdh" ( _
    ByVal hDataSource As LongPtr, _
    ByVal szWildCardPath As String, _
    ByVal mszExpandedPathList As String, _
    ByRef pcchPathListLength As Long, _
    ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

lib = Fiddle.dlopen('pdh.dll')
PdhExpandWildCardPathHA = Fiddle::Function.new(
  lib['PdhExpandWildCardPathHA'],
  [
    Fiddle::TYPE_VOIDP,  # hDataSource : PDH_HLOG optional
    Fiddle::TYPE_VOIDP,  # szWildCardPath : LPCSTR
    Fiddle::TYPE_VOIDP,  # mszExpandedPathList : LPSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchPathListLength : DWORD* in/out
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "pdh")]
extern "system" {
    fn PdhExpandWildCardPathHA(
        hDataSource: *mut core::ffi::c_void,  // PDH_HLOG optional
        szWildCardPath: *const u8,  // LPCSTR
        mszExpandedPathList: *mut u8,  // LPSTR 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.Ansi)]
public static extern uint PdhExpandWildCardPathHA(IntPtr hDataSource, [MarshalAs(UnmanagedType.LPStr)] string szWildCardPath, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder mszExpandedPathList, ref uint pcchPathListLength, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhExpandWildCardPathHA' -Namespace Win32 -PassThru
# $api::PdhExpandWildCardPathHA(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
#uselib "pdh.dll"
#func global PdhExpandWildCardPathHA "PdhExpandWildCardPathHA" sptr, sptr, sptr, sptr, sptr
; PdhExpandWildCardPathHA hDataSource, szWildCardPath, varptr(mszExpandedPathList), varptr(pcchPathListLength), dwFlags   ; 戻り値は stat
; hDataSource : PDH_HLOG optional -> "sptr"
; szWildCardPath : LPCSTR -> "sptr"
; mszExpandedPathList : LPSTR optional, out -> "sptr"
; pcchPathListLength : DWORD* in/out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "pdh.dll"
#cfunc global PdhExpandWildCardPathHA "PdhExpandWildCardPathHA" sptr, str, var, var, int
; res = PdhExpandWildCardPathHA(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
; hDataSource : PDH_HLOG optional -> "sptr"
; szWildCardPath : LPCSTR -> "str"
; mszExpandedPathList : LPSTR optional, out -> "var"
; pcchPathListLength : DWORD* in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PdhExpandWildCardPathHA(PDH_HLOG hDataSource, LPCSTR szWildCardPath, LPSTR mszExpandedPathList, DWORD* pcchPathListLength, DWORD dwFlags)
#uselib "pdh.dll"
#cfunc global PdhExpandWildCardPathHA "PdhExpandWildCardPathHA" intptr, str, var, var, int
; res = PdhExpandWildCardPathHA(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
; hDataSource : PDH_HLOG optional -> "intptr"
; szWildCardPath : LPCSTR -> "str"
; mszExpandedPathList : LPSTR 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")
	procPdhExpandWildCardPathHA = pdh.NewProc("PdhExpandWildCardPathHA")
)

// hDataSource (PDH_HLOG optional), szWildCardPath (LPCSTR), mszExpandedPathList (LPSTR optional, out), pcchPathListLength (DWORD* in/out), dwFlags (DWORD)
r1, _, err := procPdhExpandWildCardPathHA.Call(
	uintptr(hDataSource),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szWildCardPath))),
	uintptr(mszExpandedPathList),
	uintptr(pcchPathListLength),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PdhExpandWildCardPathHA(
  hDataSource: THandle;   // PDH_HLOG optional
  szWildCardPath: PAnsiChar;   // LPCSTR
  mszExpandedPathList: PAnsiChar;   // LPSTR optional, out
  pcchPathListLength: Pointer;   // DWORD* in/out
  dwFlags: DWORD   // DWORD
): DWORD; stdcall;
  external 'pdh.dll' name 'PdhExpandWildCardPathHA';
result := DllCall("pdh\PdhExpandWildCardPathHA"
    , "Ptr", hDataSource   ; PDH_HLOG optional
    , "AStr", szWildCardPath   ; LPCSTR
    , "Ptr", mszExpandedPathList   ; LPSTR optional, out
    , "Ptr", pcchPathListLength   ; DWORD* in/out
    , "UInt", dwFlags   ; DWORD
    , "UInt")   ; return: DWORD
●PdhExpandWildCardPathHA(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags) = DLL("pdh.dll", "dword PdhExpandWildCardPathHA(void*, char*, char*, void*, dword)")
# 呼び出し: PdhExpandWildCardPathHA(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
# hDataSource : PDH_HLOG optional -> "void*"
# szWildCardPath : LPCSTR -> "char*"
# mszExpandedPathList : LPSTR optional, out -> "char*"
# pcchPathListLength : DWORD* in/out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。