ホーム › System.Performance › PdhSetQueryTimeRange
PdhSetQueryTimeRange
関数ログ照会の対象とする時間範囲を設定する。
シグネチャ
// pdh.dll
#include <windows.h>
DWORD PdhSetQueryTimeRange(
PDH_HQUERY hQuery,
PDH_TIME_INFO* pInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hQuery | PDH_HQUERY | in | クエリへのハンドル。 PdhOpenQuery 関数がこのハンドルを返します。 |
| pInfo | PDH_TIME_INFO* | in | 時間範囲を指定する PDH_TIME_INFO 構造体です。時刻はローカルファイル時刻として指定します。終了時刻は開始時刻より大きくなければなりません。すべてのレコードを読み取りたい場合は、開始時刻に 0、終了時刻に 64 ビットの最大値を指定できます。 |
戻り値の型: DWORD
公式ドキュメント
ログファイルから読み取れるサンプルを、指定した時間範囲内(両端を含む)のものに制限します。
戻り値
関数が成功した場合は ERROR_SUCCESS を返します。
関数が失敗した場合、戻り値は システムエラーコード または PDH エラーコード です。指定可能な値は次のとおりです。
| 戻り値 | 説明 |
|---|---|
| クエリハンドルが無効です。 | |
| 終了時間範囲の値は、開始時間範囲の値より大きくなければなりません。 |
解説(Remarks)
指定した時間範囲の終端、またはログファイルの終端に達すると、 PdhCollectQueryData 関数は PDH_NO_MORE_DATA を返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "pdh.dll" #cfunc global PdhSetQueryTimeRange "PdhSetQueryTimeRange" sptr, sptr ; res = PdhSetQueryTimeRange(hQuery, varptr(pInfo)) ; hQuery : PDH_HQUERY -> "sptr" ; pInfo : PDH_TIME_INFO* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; DWORD PdhSetQueryTimeRange(PDH_HQUERY hQuery, PDH_TIME_INFO* pInfo) #uselib "pdh.dll" #cfunc global PdhSetQueryTimeRange "PdhSetQueryTimeRange" intptr, intptr ; res = PdhSetQueryTimeRange(hQuery, varptr(pInfo)) ; hQuery : PDH_HQUERY -> "intptr" ; pInfo : PDH_TIME_INFO* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。const std = @import("std");
extern "pdh" fn PdhSetQueryTimeRange(
hQuery: ?*anyopaque, // PDH_HQUERY
pInfo: [*c]PDH_TIME_INFO // PDH_TIME_INFO*
) callconv(std.os.windows.WINAPI) u32;proc PdhSetQueryTimeRange(
hQuery: pointer, # PDH_HQUERY
pInfo: ptr PDH_TIME_INFO # PDH_TIME_INFO*
): uint32 {.importc: "PdhSetQueryTimeRange", stdcall, dynlib: "pdh.dll".}pragma(lib, "pdh");
extern(Windows)
uint PdhSetQueryTimeRange(
void* hQuery, // PDH_HQUERY
PDH_TIME_INFO* pInfo // PDH_TIME_INFO*
);ccall((:PdhSetQueryTimeRange, "pdh.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{PDH_TIME_INFO}),
hQuery, pInfo)
# hQuery : PDH_HQUERY -> Ptr{Cvoid}
# pInfo : PDH_TIME_INFO* -> Ptr{PDH_TIME_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PdhSetQueryTimeRange(
void* hQuery,
void* pInfo);
]]
local pdh = ffi.load("pdh")
-- pdh.PdhSetQueryTimeRange(hQuery, pInfo)
-- hQuery : PDH_HQUERY
-- pInfo : PDH_TIME_INFO*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('pdh.dll');
const PdhSetQueryTimeRange = lib.func('__stdcall', 'PdhSetQueryTimeRange', 'uint32_t', ['void *', 'void *']);
// PdhSetQueryTimeRange(hQuery, pInfo)
// hQuery : PDH_HQUERY -> 'void *'
// pInfo : PDH_TIME_INFO* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("pdh.dll", {
PdhSetQueryTimeRange: { parameters: ["pointer", "pointer"], result: "u32" },
});
// lib.symbols.PdhSetQueryTimeRange(hQuery, pInfo)
// hQuery : PDH_HQUERY -> "pointer"
// pInfo : PDH_TIME_INFO* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PdhSetQueryTimeRange(
void* hQuery,
void* pInfo);
C, "pdh.dll");
// $ffi->PdhSetQueryTimeRange(hQuery, pInfo);
// hQuery : PDH_HQUERY
// pInfo : PDH_TIME_INFO*
// 構造体/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);
int PdhSetQueryTimeRange(
Pointer hQuery, // PDH_HQUERY
Pointer pInfo // PDH_TIME_INFO*
);
}@[Link("pdh")]
lib Libpdh
fun PdhSetQueryTimeRange = PdhSetQueryTimeRange(
hQuery : Void*, # PDH_HQUERY
pInfo : PDH_TIME_INFO* # PDH_TIME_INFO*
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PdhSetQueryTimeRangeNative = Uint32 Function(Pointer<Void>, Pointer<Void>);
typedef PdhSetQueryTimeRangeDart = int Function(Pointer<Void>, Pointer<Void>);
final PdhSetQueryTimeRange = DynamicLibrary.open('pdh.dll')
.lookupFunction<PdhSetQueryTimeRangeNative, PdhSetQueryTimeRangeDart>('PdhSetQueryTimeRange');
// hQuery : PDH_HQUERY -> Pointer<Void>
// pInfo : PDH_TIME_INFO* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PdhSetQueryTimeRange(
hQuery: THandle; // PDH_HQUERY
pInfo: Pointer // PDH_TIME_INFO*
): DWORD; stdcall;
external 'pdh.dll' name 'PdhSetQueryTimeRange';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PdhSetQueryTimeRange"
c_PdhSetQueryTimeRange :: Ptr () -> Ptr () -> IO Word32
-- hQuery : PDH_HQUERY -> Ptr ()
-- pInfo : PDH_TIME_INFO* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pdhsetquerytimerange =
foreign "PdhSetQueryTimeRange"
((ptr void) @-> (ptr void) @-> returning uint32_t)
(* hQuery : PDH_HQUERY -> (ptr void) *)
(* pInfo : PDH_TIME_INFO* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library pdh (t "pdh.dll"))
(cffi:use-foreign-library pdh)
(cffi:defcfun ("PdhSetQueryTimeRange" pdh-set-query-time-range :convention :stdcall) :uint32
(h-query :pointer) ; PDH_HQUERY
(p-info :pointer)) ; PDH_TIME_INFO*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PdhSetQueryTimeRange = Win32::API::More->new('pdh',
'DWORD PdhSetQueryTimeRange(HANDLE hQuery, LPVOID pInfo)');
# my $ret = $PdhSetQueryTimeRange->Call($hQuery, $pInfo);
# hQuery : PDH_HQUERY -> HANDLE
# pInfo : PDH_TIME_INFO* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f PdhCollectQueryData — 照会に追加された全カウンターの現在データを収集する。
- f PdhGetDataSourceTimeRangeW — ログデータソースに含まれる時間範囲を取得する。
- f PdhOpenQueryW — 新しいパフォーマンスデータ照会を作成して開く。
使用する型