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

PdhValidatePathExW

関数
データソース上のカウンターパスが有効か検証する。
DLLpdh.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

DWORD PdhValidatePathExW(
    PDH_HLOG hDataSource,   // optional
    LPCWSTR szFullPathBuffer
);

パラメーター

名前方向
hDataSourcePDH_HLOGinoptional
szFullPathBufferLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PdhValidatePathExW(
    PDH_HLOG hDataSource,   // optional
    LPCWSTR szFullPathBuffer
);
[DllImport("pdh.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint PdhValidatePathExW(
    IntPtr hDataSource,   // PDH_HLOG optional
    [MarshalAs(UnmanagedType.LPWStr)] string szFullPathBuffer   // LPCWSTR
);
<DllImport("pdh.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PdhValidatePathExW(
    hDataSource As IntPtr,   ' PDH_HLOG optional
    <MarshalAs(UnmanagedType.LPWStr)> szFullPathBuffer As String   ' LPCWSTR
) As UInteger
End Function
' hDataSource : PDH_HLOG optional
' szFullPathBuffer : LPCWSTR
Declare PtrSafe Function PdhValidatePathExW Lib "pdh" ( _
    ByVal hDataSource As LongPtr, _
    ByVal szFullPathBuffer 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

PdhValidatePathExW = ctypes.windll.pdh.PdhValidatePathExW
PdhValidatePathExW.restype = wintypes.DWORD
PdhValidatePathExW.argtypes = [
    wintypes.HANDLE,  # hDataSource : PDH_HLOG optional
    wintypes.LPCWSTR,  # szFullPathBuffer : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('pdh.dll')
PdhValidatePathExW = Fiddle::Function.new(
  lib['PdhValidatePathExW'],
  [
    Fiddle::TYPE_VOIDP,  # hDataSource : PDH_HLOG optional
    Fiddle::TYPE_VOIDP,  # szFullPathBuffer : LPCWSTR
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "pdh")]
extern "system" {
    fn PdhValidatePathExW(
        hDataSource: *mut core::ffi::c_void,  // PDH_HLOG optional
        szFullPathBuffer: *const u16  // LPCWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("pdh.dll", CharSet = CharSet.Unicode)]
public static extern uint PdhValidatePathExW(IntPtr hDataSource, [MarshalAs(UnmanagedType.LPWStr)] string szFullPathBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhValidatePathExW' -Namespace Win32 -PassThru
# $api::PdhValidatePathExW(hDataSource, szFullPathBuffer)
#uselib "pdh.dll"
#func global PdhValidatePathExW "PdhValidatePathExW" wptr, wptr
; PdhValidatePathExW hDataSource, szFullPathBuffer   ; 戻り値は stat
; hDataSource : PDH_HLOG optional -> "wptr"
; szFullPathBuffer : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "pdh.dll"
#cfunc global PdhValidatePathExW "PdhValidatePathExW" sptr, wstr
; res = PdhValidatePathExW(hDataSource, szFullPathBuffer)
; hDataSource : PDH_HLOG optional -> "sptr"
; szFullPathBuffer : LPCWSTR -> "wstr"
; DWORD PdhValidatePathExW(PDH_HLOG hDataSource, LPCWSTR szFullPathBuffer)
#uselib "pdh.dll"
#cfunc global PdhValidatePathExW "PdhValidatePathExW" intptr, wstr
; res = PdhValidatePathExW(hDataSource, szFullPathBuffer)
; hDataSource : PDH_HLOG optional -> "intptr"
; szFullPathBuffer : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	pdh = windows.NewLazySystemDLL("pdh.dll")
	procPdhValidatePathExW = pdh.NewProc("PdhValidatePathExW")
)

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