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