ホーム › System.WindowsProgramming › QueryInterruptTime
QueryInterruptTime
関数現在の割り込み時間カウンタ値を取得する。
シグネチャ
// api-ms-win-core-realtime-l1-1-1.dll
#include <windows.h>
void QueryInterruptTime(
ULONGLONG* lpInterruptTime
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpInterruptTime | ULONGLONG* | out | 現在の割り込み時間(100ナノ秒単位)を受け取る出力ポインタ。 |
戻り値の型: void
各言語での呼び出し定義
// api-ms-win-core-realtime-l1-1-1.dll
#include <windows.h>
void QueryInterruptTime(
ULONGLONG* lpInterruptTime
);[DllImport("api-ms-win-core-realtime-l1-1-1.dll", ExactSpelling = true)]
static extern void QueryInterruptTime(
out ulong lpInterruptTime // ULONGLONG* out
);<DllImport("api-ms-win-core-realtime-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Sub QueryInterruptTime(
<Out> ByRef lpInterruptTime As ULong ' ULONGLONG* out
)
End Sub' lpInterruptTime : ULONGLONG* out
Declare PtrSafe Sub QueryInterruptTime Lib "api-ms-win-core-realtime-l1-1-1" ( _
ByRef lpInterruptTime As LongLong)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
QueryInterruptTime = ctypes.windll.LoadLibrary("api-ms-win-core-realtime-l1-1-1.dll").QueryInterruptTime
QueryInterruptTime.restype = None
QueryInterruptTime.argtypes = [
ctypes.POINTER(ctypes.c_ulonglong), # lpInterruptTime : ULONGLONG* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-core-realtime-l1-1-1.dll')
QueryInterruptTime = Fiddle::Function.new(
lib['QueryInterruptTime'],
[
Fiddle::TYPE_VOIDP, # lpInterruptTime : ULONGLONG* out
],
Fiddle::TYPE_VOID)#[link(name = "api-ms-win-core-realtime-l1-1-1")]
extern "system" {
fn QueryInterruptTime(
lpInterruptTime: *mut u64 // ULONGLONG* out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-core-realtime-l1-1-1.dll")]
public static extern void QueryInterruptTime(out ulong lpInterruptTime);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-realtime-l1-1-1_QueryInterruptTime' -Namespace Win32 -PassThru
# $api::QueryInterruptTime(lpInterruptTime)#uselib "api-ms-win-core-realtime-l1-1-1.dll"
#func global QueryInterruptTime "QueryInterruptTime" sptr
; QueryInterruptTime varptr(lpInterruptTime)
; lpInterruptTime : ULONGLONG* out -> "sptr"出力引数:
#uselib "api-ms-win-core-realtime-l1-1-1.dll" #func global QueryInterruptTime "QueryInterruptTime" var ; QueryInterruptTime lpInterruptTime ; lpInterruptTime : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-core-realtime-l1-1-1.dll" #func global QueryInterruptTime "QueryInterruptTime" sptr ; QueryInterruptTime varptr(lpInterruptTime) ; lpInterruptTime : ULONGLONG* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void QueryInterruptTime(ULONGLONG* lpInterruptTime) #uselib "api-ms-win-core-realtime-l1-1-1.dll" #func global QueryInterruptTime "QueryInterruptTime" var ; QueryInterruptTime lpInterruptTime ; lpInterruptTime : ULONGLONG* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void QueryInterruptTime(ULONGLONG* lpInterruptTime) #uselib "api-ms-win-core-realtime-l1-1-1.dll" #func global QueryInterruptTime "QueryInterruptTime" intptr ; QueryInterruptTime varptr(lpInterruptTime) ; lpInterruptTime : ULONGLONG* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_core_realtime_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-core-realtime-l1-1-1.dll")
procQueryInterruptTime = api_ms_win_core_realtime_l1_1_1.NewProc("QueryInterruptTime")
)
// lpInterruptTime (ULONGLONG* out)
r1, _, err := procQueryInterruptTime.Call(
uintptr(lpInterruptTime),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure QueryInterruptTime(
lpInterruptTime: Pointer // ULONGLONG* out
); stdcall;
external 'api-ms-win-core-realtime-l1-1-1.dll' name 'QueryInterruptTime';result := DllCall("api-ms-win-core-realtime-l1-1-1\QueryInterruptTime"
, "Ptr", lpInterruptTime ; ULONGLONG* out
, "Int") ; return: void●QueryInterruptTime(lpInterruptTime) = DLL("api-ms-win-core-realtime-l1-1-1.dll", "int QueryInterruptTime(void*)")
# 呼び出し: QueryInterruptTime(lpInterruptTime)
# lpInterruptTime : ULONGLONG* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "api-ms-win-core-realtime-l1-1-1" fn QueryInterruptTime(
lpInterruptTime: [*c]u64 // ULONGLONG* out
) callconv(std.os.windows.WINAPI) void;proc QueryInterruptTime(
lpInterruptTime: ptr uint64 # ULONGLONG* out
) {.importc: "QueryInterruptTime", stdcall, dynlib: "api-ms-win-core-realtime-l1-1-1.dll".}pragma(lib, "api-ms-win-core-realtime-l1-1-1");
extern(Windows)
void QueryInterruptTime(
ulong* lpInterruptTime // ULONGLONG* out
);ccall((:QueryInterruptTime, "api-ms-win-core-realtime-l1-1-1.dll"), stdcall, Cvoid,
(Ptr{UInt64},),
lpInterruptTime)
# lpInterruptTime : ULONGLONG* out -> Ptr{UInt64}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void QueryInterruptTime(
uint64_t* lpInterruptTime);
]]
local api-ms-win-core-realtime-l1-1-1 = ffi.load("api-ms-win-core-realtime-l1-1-1")
-- api-ms-win-core-realtime-l1-1-1.QueryInterruptTime(lpInterruptTime)
-- lpInterruptTime : ULONGLONG* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-realtime-l1-1-1.dll');
const QueryInterruptTime = lib.func('__stdcall', 'QueryInterruptTime', 'void', ['uint64_t *']);
// QueryInterruptTime(lpInterruptTime)
// lpInterruptTime : ULONGLONG* out -> 'uint64_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-core-realtime-l1-1-1.dll", {
QueryInterruptTime: { parameters: ["pointer"], result: "void" },
});
// lib.symbols.QueryInterruptTime(lpInterruptTime)
// lpInterruptTime : ULONGLONG* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void QueryInterruptTime(
uint64_t* lpInterruptTime);
C, "api-ms-win-core-realtime-l1-1-1.dll");
// $ffi->QueryInterruptTime(lpInterruptTime);
// lpInterruptTime : ULONGLONG* out
// 構造体/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 Api-ms-win-core-realtime-l1-1-1 extends StdCallLibrary {
Api-ms-win-core-realtime-l1-1-1 INSTANCE = Native.load("api-ms-win-core-realtime-l1-1-1", Api-ms-win-core-realtime-l1-1-1.class);
void QueryInterruptTime(
LongByReference lpInterruptTime // ULONGLONG* out
);
}@[Link("api-ms-win-core-realtime-l1-1-1")]
lib Libapi-ms-win-core-realtime-l1-1-1
fun QueryInterruptTime = QueryInterruptTime(
lpInterruptTime : UInt64* # ULONGLONG* out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef QueryInterruptTimeNative = Void Function(Pointer<Uint64>);
typedef QueryInterruptTimeDart = void Function(Pointer<Uint64>);
final QueryInterruptTime = DynamicLibrary.open('api-ms-win-core-realtime-l1-1-1.dll')
.lookupFunction<QueryInterruptTimeNative, QueryInterruptTimeDart>('QueryInterruptTime');
// lpInterruptTime : ULONGLONG* out -> Pointer<Uint64>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure QueryInterruptTime(
lpInterruptTime: Pointer // ULONGLONG* out
); stdcall;
external 'api-ms-win-core-realtime-l1-1-1.dll' name 'QueryInterruptTime';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "QueryInterruptTime"
c_QueryInterruptTime :: Ptr Word64 -> IO ()
-- lpInterruptTime : ULONGLONG* out -> Ptr Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let queryinterrupttime =
foreign "QueryInterruptTime"
((ptr uint64_t) @-> returning void)
(* lpInterruptTime : ULONGLONG* out -> (ptr uint64_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-realtime-l1-1-1 (t "api-ms-win-core-realtime-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-core-realtime-l1-1-1)
(cffi:defcfun ("QueryInterruptTime" query-interrupt-time :convention :stdcall) :void
(lp-interrupt-time :pointer)) ; ULONGLONG* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $QueryInterruptTime = Win32::API::More->new('api-ms-win-core-realtime-l1-1-1',
'void QueryInterruptTime(LPVOID lpInterruptTime)');
# my $ret = $QueryInterruptTime->Call($lpInterruptTime);
# lpInterruptTime : ULONGLONG* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。