ホーム › System.WindowsProgramming › QueryIdleProcessorCycleTimeEx
QueryIdleProcessorCycleTimeEx
関数指定プロセッサグループのアイドルサイクル時間を取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL QueryIdleProcessorCycleTimeEx(
WORD Group,
DWORD* BufferLength,
ULONGLONG* ProcessorIdleCycleTime // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Group | WORD | in |
| BufferLength | DWORD* | inout |
| ProcessorIdleCycleTime | ULONGLONG* | outoptional |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL QueryIdleProcessorCycleTimeEx(
WORD Group,
DWORD* BufferLength,
ULONGLONG* ProcessorIdleCycleTime // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool QueryIdleProcessorCycleTimeEx(
ushort Group, // WORD
ref uint BufferLength, // DWORD* in/out
IntPtr ProcessorIdleCycleTime // ULONGLONG* optional, out
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function QueryIdleProcessorCycleTimeEx(
Group As UShort, ' WORD
ByRef BufferLength As UInteger, ' DWORD* in/out
ProcessorIdleCycleTime As IntPtr ' ULONGLONG* optional, out
) As Boolean
End Function' Group : WORD
' BufferLength : DWORD* in/out
' ProcessorIdleCycleTime : ULONGLONG* optional, out
Declare PtrSafe Function QueryIdleProcessorCycleTimeEx Lib "kernel32" ( _
ByVal Group As Integer, _
ByRef BufferLength As Long, _
ByVal ProcessorIdleCycleTime As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
QueryIdleProcessorCycleTimeEx = ctypes.windll.kernel32.QueryIdleProcessorCycleTimeEx
QueryIdleProcessorCycleTimeEx.restype = wintypes.BOOL
QueryIdleProcessorCycleTimeEx.argtypes = [
ctypes.c_ushort, # Group : WORD
ctypes.POINTER(wintypes.DWORD), # BufferLength : DWORD* in/out
ctypes.POINTER(ctypes.c_ulonglong), # ProcessorIdleCycleTime : ULONGLONG* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
QueryIdleProcessorCycleTimeEx = Fiddle::Function.new(
lib['QueryIdleProcessorCycleTimeEx'],
[
-Fiddle::TYPE_SHORT, # Group : WORD
Fiddle::TYPE_VOIDP, # BufferLength : DWORD* in/out
Fiddle::TYPE_VOIDP, # ProcessorIdleCycleTime : ULONGLONG* optional, out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn QueryIdleProcessorCycleTimeEx(
Group: u16, // WORD
BufferLength: *mut u32, // DWORD* in/out
ProcessorIdleCycleTime: *mut u64 // ULONGLONG* optional, out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool QueryIdleProcessorCycleTimeEx(ushort Group, ref uint BufferLength, IntPtr ProcessorIdleCycleTime);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_QueryIdleProcessorCycleTimeEx' -Namespace Win32 -PassThru
# $api::QueryIdleProcessorCycleTimeEx(Group, BufferLength, ProcessorIdleCycleTime)#uselib "KERNEL32.dll"
#func global QueryIdleProcessorCycleTimeEx "QueryIdleProcessorCycleTimeEx" sptr, sptr, sptr
; QueryIdleProcessorCycleTimeEx Group, varptr(BufferLength), varptr(ProcessorIdleCycleTime) ; 戻り値は stat
; Group : WORD -> "sptr"
; BufferLength : DWORD* in/out -> "sptr"
; ProcessorIdleCycleTime : ULONGLONG* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global QueryIdleProcessorCycleTimeEx "QueryIdleProcessorCycleTimeEx" int, var, var ; res = QueryIdleProcessorCycleTimeEx(Group, BufferLength, ProcessorIdleCycleTime) ; Group : WORD -> "int" ; BufferLength : DWORD* in/out -> "var" ; ProcessorIdleCycleTime : ULONGLONG* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global QueryIdleProcessorCycleTimeEx "QueryIdleProcessorCycleTimeEx" int, sptr, sptr ; res = QueryIdleProcessorCycleTimeEx(Group, varptr(BufferLength), varptr(ProcessorIdleCycleTime)) ; Group : WORD -> "int" ; BufferLength : DWORD* in/out -> "sptr" ; ProcessorIdleCycleTime : ULONGLONG* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL QueryIdleProcessorCycleTimeEx(WORD Group, DWORD* BufferLength, ULONGLONG* ProcessorIdleCycleTime) #uselib "KERNEL32.dll" #cfunc global QueryIdleProcessorCycleTimeEx "QueryIdleProcessorCycleTimeEx" int, var, var ; res = QueryIdleProcessorCycleTimeEx(Group, BufferLength, ProcessorIdleCycleTime) ; Group : WORD -> "int" ; BufferLength : DWORD* in/out -> "var" ; ProcessorIdleCycleTime : ULONGLONG* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL QueryIdleProcessorCycleTimeEx(WORD Group, DWORD* BufferLength, ULONGLONG* ProcessorIdleCycleTime) #uselib "KERNEL32.dll" #cfunc global QueryIdleProcessorCycleTimeEx "QueryIdleProcessorCycleTimeEx" int, intptr, intptr ; res = QueryIdleProcessorCycleTimeEx(Group, varptr(BufferLength), varptr(ProcessorIdleCycleTime)) ; Group : WORD -> "int" ; BufferLength : DWORD* in/out -> "intptr" ; ProcessorIdleCycleTime : ULONGLONG* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procQueryIdleProcessorCycleTimeEx = kernel32.NewProc("QueryIdleProcessorCycleTimeEx")
)
// Group (WORD), BufferLength (DWORD* in/out), ProcessorIdleCycleTime (ULONGLONG* optional, out)
r1, _, err := procQueryIdleProcessorCycleTimeEx.Call(
uintptr(Group),
uintptr(BufferLength),
uintptr(ProcessorIdleCycleTime),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction QueryIdleProcessorCycleTimeEx(
Group: Word; // WORD
BufferLength: Pointer; // DWORD* in/out
ProcessorIdleCycleTime: Pointer // ULONGLONG* optional, out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'QueryIdleProcessorCycleTimeEx';result := DllCall("KERNEL32\QueryIdleProcessorCycleTimeEx"
, "UShort", Group ; WORD
, "Ptr", BufferLength ; DWORD* in/out
, "Ptr", ProcessorIdleCycleTime ; ULONGLONG* optional, out
, "Int") ; return: BOOL●QueryIdleProcessorCycleTimeEx(Group, BufferLength, ProcessorIdleCycleTime) = DLL("KERNEL32.dll", "bool QueryIdleProcessorCycleTimeEx(int, void*, void*)")
# 呼び出し: QueryIdleProcessorCycleTimeEx(Group, BufferLength, ProcessorIdleCycleTime)
# Group : WORD -> "int"
# BufferLength : DWORD* in/out -> "void*"
# ProcessorIdleCycleTime : ULONGLONG* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。