PdhExpandWildCardPathHW
関数シグネチャ
// pdh.dll (Unicode / -W)
#include <windows.h>
DWORD PdhExpandWildCardPathHW(
PDH_HLOG hDataSource, // optional
LPCWSTR szWildCardPath,
LPWSTR mszExpandedPathList, // optional
DWORD* pcchPathListLength,
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| hDataSource | PDH_HLOG | inoptional | PdhBindInputDataSource 関数が返すデータソースへのハンドルです。 | ||||||||
| szWildCardPath | LPCWSTR | in | 展開するカウンターパスを指定する Null 終端文字列です。カウンターパスの最大長は PDH_MAX_COUNTER_PATH です。 hDataSource がリアルタイムのデータソースである場合、この関数はパスで指定されたコンピューターを検索して一致を探します。パスにコンピューターが指定されていない場合は、ローカルコンピューターを検索します。 | ||||||||
| mszExpandedPathList | LPWSTR | outoptional | szWildCardPath のワイルドカード指定に一致する null 終端カウンターパスのリストを受け取る、呼び出し側が割り当てたバッファーです。リストは 2 つの NULL 文字で終端されます。pcchPathListLength がゼロの場合は NULL に設定します。 | ||||||||
| pcchPathListLength | DWORD* | inout | mszExpandedPathList バッファーのサイズ(TCHAR 単位)です。入力時にゼロでオブジェクトが存在する場合、この関数は PDH_MORE_DATA を返し、このパラメーターに必要なバッファーサイズを設定します。バッファーが必要なサイズより大きい場合、この関数はこのパラメーターに実際に使用されたバッファーのサイズを設定します。入力時に指定したサイズがゼロより大きく必要なサイズより小さい場合、返されたサイズを基にバッファーを再割り当てしないでください。 注意 Windows XP では、必要なサイズに 1 を加算する必要があります。
| ||||||||
| dwFlags | DWORD | in | 展開しないワイルドカード文字を示すフラグです。1 つ以上のフラグを指定できます。
|
戻り値の型: DWORD
公式ドキュメント
指定したコンピューターまたはログファイルを調べ、ワイルドカード文字を含む指定のカウンターパスに一致するカウンターパスを返します。この関数は、データソースへのハンドルの使用をサポートする点を除いて、PdhExpandWildCardPath 関数と同一です。(Unicode)
戻り値
関数が成功した場合は ERROR_SUCCESS を返します。
関数が失敗した場合、戻り値は システムエラーコード または PDH エラーコード です。
| 戻り値 | 説明 |
|---|---|
| mszExpandedPathList バッファーがパスのリストを格納するのに十分な大きさではありません。この戻り値は、入力時に pcchPathListLength がゼロの場合に想定されるものです。入力時に指定したサイズがゼロより大きく必要なサイズより小さい場合、返されたサイズを基にバッファーを再割り当てしないでください。 | |
| パラメーターが無効です。たとえば、一部のリリースでは、入力時に指定したサイズがゼロより大きく必要なサイズより小さい場合にこのエラーを受け取ることがあります。 | |
| この関数をサポートするためのメモリを割り当てることができません。 | |
| コンピューターまたはログファイル内で指定されたオブジェクトを見つけることができません。 |
解説(Remarks)
この関数は 2 回呼び出す必要があります。1 回目は必要なバッファーサイズを取得するため(mszExpandedPathList を NULL に、pcchPathListLength を 0 に設定)、2 回目はデータを取得するためです。
PdhExpandWildCardPathH は、次の点で PdhExpandCounterPath と異なります。
- 展開するワイルドカード文字を制御できます。
- ログファイルの内容をカウンター名のソースとして使用できます。
\computer\object(parent/instance#index)\counter
カウンターパスの parent、instance、index、counter の各コンポーネントには、有効な名前またはワイルドカード文字のいずれかを含めることができます。computer、parent、instance、index の各コンポーネントは、すべてのカウンターで必要なわけではありません。
指定可能な形式の一覧は次のとおりです。
- \\computer\object(parent/instance#index)\counter
- \\computer\object(parent/instance)\counter
- \\computer\object(instance#index)\counter
- \\computer\object(instance)\counter
- \\computer\object\counter
- \object(parent/instance#index)\counter
- \object(parent/instance)\counter
- \object(instance#index)\counter
- \object(instance)\counter
- \object\counter
親名にワイルドカード文字が指定されている場合、指定された instance フィールドおよび counter フィールドに一致する、指定オブジェクトのすべてのインスタンスが返されます。たとえば、\object(*/instance)\counter のようになります。
インスタンス名にワイルドカード文字が指定されている場合、指定インデックスに対応するすべてのインスタンス名がワイルドカード文字に一致すれば、指定オブジェクトおよび親オブジェクトのすべてのインスタンスが返されます。たとえば、\object(parent/*)\counter のようになります。
カウンター名にワイルドカード文字が指定されている場合、指定オブジェクトのすべてのカウンターが返されます。
カウンターパス文字列の部分一致(たとえば "pro*")がサポートされます。
Windows Vista より前: 部分的なワイルドカード一致はサポートされていません。
pdh.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして PdhExpandWildCardPathH を定義しています。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じてコンパイルエラーまたは実行時エラーになることがあります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "pdh.dll" #cfunc global PdhExpandWildCardPathHW "PdhExpandWildCardPathHW" sptr, wstr, sptr, sptr, int ; res = PdhExpandWildCardPathHW(hDataSource, szWildCardPath, varptr(mszExpandedPathList), varptr(pcchPathListLength), dwFlags) ; hDataSource : PDH_HLOG optional -> "sptr" ; szWildCardPath : LPCWSTR -> "wstr" ; mszExpandedPathList : LPWSTR optional, out -> "sptr" ; pcchPathListLength : DWORD* in/out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; DWORD PdhExpandWildCardPathHW(PDH_HLOG hDataSource, LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, DWORD* pcchPathListLength, DWORD dwFlags) #uselib "pdh.dll" #cfunc global PdhExpandWildCardPathHW "PdhExpandWildCardPathHW" intptr, wstr, intptr, intptr, int ; res = PdhExpandWildCardPathHW(hDataSource, szWildCardPath, varptr(mszExpandedPathList), varptr(pcchPathListLength), dwFlags) ; hDataSource : PDH_HLOG optional -> "intptr" ; szWildCardPath : LPCWSTR -> "wstr" ; mszExpandedPathList : LPWSTR optional, out -> "intptr" ; pcchPathListLength : DWORD* in/out -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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 版の利用を推奨。const std = @import("std");
extern "pdh" fn PdhExpandWildCardPathHW(
hDataSource: ?*anyopaque, // PDH_HLOG optional
szWildCardPath: [*c]const u16, // LPCWSTR
mszExpandedPathList: [*c]u16, // LPWSTR optional, out
pcchPathListLength: [*c]u32, // DWORD* in/out
dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc PdhExpandWildCardPathHW(
hDataSource: pointer, # PDH_HLOG optional
szWildCardPath: WideCString, # LPCWSTR
mszExpandedPathList: ptr uint16, # LPWSTR optional, out
pcchPathListLength: ptr uint32, # DWORD* in/out
dwFlags: uint32 # DWORD
): uint32 {.importc: "PdhExpandWildCardPathHW", stdcall, dynlib: "pdh.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "pdh");
extern(Windows)
uint PdhExpandWildCardPathHW(
void* hDataSource, // PDH_HLOG optional
const(wchar)* szWildCardPath, // LPCWSTR
wchar* mszExpandedPathList, // LPWSTR optional, out
uint* pcchPathListLength, // DWORD* in/out
uint dwFlags // DWORD
);ccall((:PdhExpandWildCardPathHW, "pdh.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, Ptr{UInt16}, Ptr{UInt32}, UInt32),
hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
# hDataSource : PDH_HLOG optional -> Ptr{Cvoid}
# szWildCardPath : LPCWSTR -> Cwstring
# mszExpandedPathList : LPWSTR optional, out -> Ptr{UInt16}
# pcchPathListLength : DWORD* in/out -> Ptr{UInt32}
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t PdhExpandWildCardPathHW(
void* hDataSource,
const uint16_t* szWildCardPath,
uint16_t* mszExpandedPathList,
uint32_t* pcchPathListLength,
uint32_t dwFlags);
]]
local pdh = ffi.load("pdh")
-- pdh.PdhExpandWildCardPathHW(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
-- hDataSource : PDH_HLOG optional
-- szWildCardPath : LPCWSTR
-- mszExpandedPathList : LPWSTR optional, out
-- pcchPathListLength : DWORD* in/out
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('pdh.dll');
const PdhExpandWildCardPathHW = lib.func('__stdcall', 'PdhExpandWildCardPathHW', 'uint32_t', ['void *', 'str16', 'uint16_t *', 'uint32_t *', 'uint32_t']);
// PdhExpandWildCardPathHW(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
// hDataSource : PDH_HLOG optional -> 'void *'
// szWildCardPath : LPCWSTR -> 'str16'
// mszExpandedPathList : LPWSTR optional, out -> 'uint16_t *'
// pcchPathListLength : DWORD* in/out -> 'uint32_t *'
// dwFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("pdh.dll", {
PdhExpandWildCardPathHW: { parameters: ["pointer", "buffer", "buffer", "pointer", "u32"], result: "u32" },
});
// lib.symbols.PdhExpandWildCardPathHW(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags)
// hDataSource : PDH_HLOG optional -> "pointer"
// szWildCardPath : LPCWSTR -> "buffer"
// mszExpandedPathList : LPWSTR optional, out -> "buffer"
// pcchPathListLength : DWORD* in/out -> "pointer"
// dwFlags : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PdhExpandWildCardPathHW(
void* hDataSource,
const uint16_t* szWildCardPath,
uint16_t* mszExpandedPathList,
uint32_t* pcchPathListLength,
uint32_t dwFlags);
C, "pdh.dll");
// $ffi->PdhExpandWildCardPathHW(hDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags);
// hDataSource : PDH_HLOG optional
// szWildCardPath : LPCWSTR
// mszExpandedPathList : LPWSTR optional, out
// pcchPathListLength : DWORD* in/out
// dwFlags : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Pdh extends StdCallLibrary {
Pdh INSTANCE = Native.load("pdh", Pdh.class, W32APIOptions.UNICODE_OPTIONS);
int PdhExpandWildCardPathHW(
Pointer hDataSource, // PDH_HLOG optional
WString szWildCardPath, // LPCWSTR
char[] mszExpandedPathList, // LPWSTR optional, out
IntByReference pcchPathListLength, // DWORD* in/out
int dwFlags // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("pdh")]
lib Libpdh
fun PdhExpandWildCardPathHW = PdhExpandWildCardPathHW(
hDataSource : Void*, # PDH_HLOG optional
szWildCardPath : UInt16*, # LPCWSTR
mszExpandedPathList : UInt16*, # LPWSTR optional, out
pcchPathListLength : UInt32*, # DWORD* in/out
dwFlags : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PdhExpandWildCardPathHWNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>, Uint32);
typedef PdhExpandWildCardPathHWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Pointer<Uint32>, int);
final PdhExpandWildCardPathHW = DynamicLibrary.open('pdh.dll')
.lookupFunction<PdhExpandWildCardPathHWNative, PdhExpandWildCardPathHWDart>('PdhExpandWildCardPathHW');
// hDataSource : PDH_HLOG optional -> Pointer<Void>
// szWildCardPath : LPCWSTR -> Pointer<Utf16>
// mszExpandedPathList : LPWSTR optional, out -> Pointer<Utf16>
// pcchPathListLength : DWORD* in/out -> Pointer<Uint32>
// dwFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PdhExpandWildCardPathHW"
c_PdhExpandWildCardPathHW :: Ptr () -> CWString -> CWString -> Ptr Word32 -> Word32 -> IO Word32
-- hDataSource : PDH_HLOG optional -> Ptr ()
-- szWildCardPath : LPCWSTR -> CWString
-- mszExpandedPathList : LPWSTR optional, out -> CWString
-- pcchPathListLength : DWORD* in/out -> Ptr Word32
-- dwFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pdhexpandwildcardpathhw =
foreign "PdhExpandWildCardPathHW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> uint32_t @-> returning uint32_t)
(* hDataSource : PDH_HLOG optional -> (ptr void) *)
(* szWildCardPath : LPCWSTR -> (ptr uint16_t) *)
(* mszExpandedPathList : LPWSTR optional, out -> (ptr uint16_t) *)
(* pcchPathListLength : DWORD* in/out -> (ptr uint32_t) *)
(* dwFlags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library pdh (t "pdh.dll"))
(cffi:use-foreign-library pdh)
(cffi:defcfun ("PdhExpandWildCardPathHW" pdh-expand-wild-card-path-hw :convention :stdcall) :uint32
(h-data-source :pointer) ; PDH_HLOG optional
(sz-wild-card-path (:string :encoding :utf-16le)) ; LPCWSTR
(msz-expanded-path-list :pointer) ; LPWSTR optional, out
(pcch-path-list-length :pointer) ; DWORD* in/out
(dw-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PdhExpandWildCardPathHW = Win32::API::More->new('pdh',
'DWORD PdhExpandWildCardPathHW(HANDLE hDataSource, LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, LPVOID pcchPathListLength, DWORD dwFlags)');
# my $ret = $PdhExpandWildCardPathHW->Call($hDataSource, $szWildCardPath, $mszExpandedPathList, $pcchPathListLength, $dwFlags);
# hDataSource : PDH_HLOG optional -> HANDLE
# szWildCardPath : LPCWSTR -> LPCWSTR
# mszExpandedPathList : LPWSTR optional, out -> LPWSTR
# pcchPathListLength : DWORD* in/out -> LPVOID
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f PdhExpandWildCardPathHA (ANSI版) — ハンドル指定でワイルドカードパスを展開する(ANSI版)。