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