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