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

PdhSetQueryTimeRange

関数
ログ照会の対象とする時間範囲を設定する。
DLLpdh.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// pdh.dll
#include <windows.h>

DWORD PdhSetQueryTimeRange(
    PDH_HQUERY hQuery,
    PDH_TIME_INFO* pInfo
);

パラメーター

名前方向
hQueryPDH_HQUERYin
pInfoPDH_TIME_INFO*in

戻り値の型: DWORD

各言語での呼び出し定義

// pdh.dll
#include <windows.h>

DWORD PdhSetQueryTimeRange(
    PDH_HQUERY hQuery,
    PDH_TIME_INFO* pInfo
);
[DllImport("pdh.dll", ExactSpelling = true)]
static extern uint PdhSetQueryTimeRange(
    IntPtr hQuery,   // PDH_HQUERY
    IntPtr pInfo   // PDH_TIME_INFO*
);
<DllImport("pdh.dll", ExactSpelling:=True)>
Public Shared Function PdhSetQueryTimeRange(
    hQuery As IntPtr,   ' PDH_HQUERY
    pInfo As IntPtr   ' PDH_TIME_INFO*
) As UInteger
End Function
' hQuery : PDH_HQUERY
' pInfo : PDH_TIME_INFO*
Declare PtrSafe Function PdhSetQueryTimeRange Lib "pdh" ( _
    ByVal hQuery As LongPtr, _
    ByVal pInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PdhSetQueryTimeRange = ctypes.windll.pdh.PdhSetQueryTimeRange
PdhSetQueryTimeRange.restype = wintypes.DWORD
PdhSetQueryTimeRange.argtypes = [
    wintypes.HANDLE,  # hQuery : PDH_HQUERY
    ctypes.c_void_p,  # pInfo : PDH_TIME_INFO*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('pdh.dll')
PdhSetQueryTimeRange = Fiddle::Function.new(
  lib['PdhSetQueryTimeRange'],
  [
    Fiddle::TYPE_VOIDP,  # hQuery : PDH_HQUERY
    Fiddle::TYPE_VOIDP,  # pInfo : PDH_TIME_INFO*
  ],
  -Fiddle::TYPE_INT)
#[link(name = "pdh")]
extern "system" {
    fn PdhSetQueryTimeRange(
        hQuery: *mut core::ffi::c_void,  // PDH_HQUERY
        pInfo: *mut PDH_TIME_INFO  // PDH_TIME_INFO*
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("pdh.dll")]
public static extern uint PdhSetQueryTimeRange(IntPtr hQuery, IntPtr pInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'pdh_PdhSetQueryTimeRange' -Namespace Win32 -PassThru
# $api::PdhSetQueryTimeRange(hQuery, pInfo)
#uselib "pdh.dll"
#func global PdhSetQueryTimeRange "PdhSetQueryTimeRange" sptr, sptr
; PdhSetQueryTimeRange hQuery, varptr(pInfo)   ; 戻り値は stat
; hQuery : PDH_HQUERY -> "sptr"
; pInfo : PDH_TIME_INFO* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "pdh.dll"
#cfunc global PdhSetQueryTimeRange "PdhSetQueryTimeRange" sptr, var
; res = PdhSetQueryTimeRange(hQuery, pInfo)
; hQuery : PDH_HQUERY -> "sptr"
; pInfo : PDH_TIME_INFO* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PdhSetQueryTimeRange(PDH_HQUERY hQuery, PDH_TIME_INFO* pInfo)
#uselib "pdh.dll"
#cfunc global PdhSetQueryTimeRange "PdhSetQueryTimeRange" intptr, var
; res = PdhSetQueryTimeRange(hQuery, pInfo)
; hQuery : PDH_HQUERY -> "intptr"
; pInfo : PDH_TIME_INFO* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	pdh = windows.NewLazySystemDLL("pdh.dll")
	procPdhSetQueryTimeRange = pdh.NewProc("PdhSetQueryTimeRange")
)

// hQuery (PDH_HQUERY), pInfo (PDH_TIME_INFO*)
r1, _, err := procPdhSetQueryTimeRange.Call(
	uintptr(hQuery),
	uintptr(pInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PdhSetQueryTimeRange(
  hQuery: THandle;   // PDH_HQUERY
  pInfo: Pointer   // PDH_TIME_INFO*
): DWORD; stdcall;
  external 'pdh.dll' name 'PdhSetQueryTimeRange';
result := DllCall("pdh\PdhSetQueryTimeRange"
    , "Ptr", hQuery   ; PDH_HQUERY
    , "Ptr", pInfo   ; PDH_TIME_INFO*
    , "UInt")   ; return: DWORD
●PdhSetQueryTimeRange(hQuery, pInfo) = DLL("pdh.dll", "dword PdhSetQueryTimeRange(void*, void*)")
# 呼び出し: PdhSetQueryTimeRange(hQuery, pInfo)
# hQuery : PDH_HQUERY -> "void*"
# pInfo : PDH_TIME_INFO* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。