Win32 API 日本語リファレンス
ホームSystem.Hypervisor › WHvGetVpciDeviceProperty

WHvGetVpciDeviceProperty

関数
仮想PCIデバイスのプロパティ情報を取得する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

// WinHvPlatform.dll
#include <windows.h>

HRESULT WHvGetVpciDeviceProperty(
    WHV_PARTITION_HANDLE Partition,
    ULONGLONG LogicalDeviceId,
    WHV_VPCI_DEVICE_PROPERTY_CODE PropertyCode,
    void* PropertyBuffer,
    DWORD PropertyBufferSizeInBytes,
    DWORD* WrittenSizeInBytes   // optional
);

パラメーター

名前方向
PartitionWHV_PARTITION_HANDLEin
LogicalDeviceIdULONGLONGin
PropertyCodeWHV_VPCI_DEVICE_PROPERTY_CODEin
PropertyBuffervoid*out
PropertyBufferSizeInBytesDWORDin
WrittenSizeInBytesDWORD*outoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// WinHvPlatform.dll
#include <windows.h>

HRESULT WHvGetVpciDeviceProperty(
    WHV_PARTITION_HANDLE Partition,
    ULONGLONG LogicalDeviceId,
    WHV_VPCI_DEVICE_PROPERTY_CODE PropertyCode,
    void* PropertyBuffer,
    DWORD PropertyBufferSizeInBytes,
    DWORD* WrittenSizeInBytes   // optional
);
[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvGetVpciDeviceProperty(
    IntPtr Partition,   // WHV_PARTITION_HANDLE
    ulong LogicalDeviceId,   // ULONGLONG
    int PropertyCode,   // WHV_VPCI_DEVICE_PROPERTY_CODE
    IntPtr PropertyBuffer,   // void* out
    uint PropertyBufferSizeInBytes,   // DWORD
    IntPtr WrittenSizeInBytes   // DWORD* optional, out
);
<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvGetVpciDeviceProperty(
    Partition As IntPtr,   ' WHV_PARTITION_HANDLE
    LogicalDeviceId As ULong,   ' ULONGLONG
    PropertyCode As Integer,   ' WHV_VPCI_DEVICE_PROPERTY_CODE
    PropertyBuffer As IntPtr,   ' void* out
    PropertyBufferSizeInBytes As UInteger,   ' DWORD
    WrittenSizeInBytes As IntPtr   ' DWORD* optional, out
) As Integer
End Function
' Partition : WHV_PARTITION_HANDLE
' LogicalDeviceId : ULONGLONG
' PropertyCode : WHV_VPCI_DEVICE_PROPERTY_CODE
' PropertyBuffer : void* out
' PropertyBufferSizeInBytes : DWORD
' WrittenSizeInBytes : DWORD* optional, out
Declare PtrSafe Function WHvGetVpciDeviceProperty Lib "winhvplatform" ( _
    ByVal Partition As LongPtr, _
    ByVal LogicalDeviceId As LongLong, _
    ByVal PropertyCode As Long, _
    ByVal PropertyBuffer As LongPtr, _
    ByVal PropertyBufferSizeInBytes As Long, _
    ByVal WrittenSizeInBytes As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvGetVpciDeviceProperty = ctypes.windll.winhvplatform.WHvGetVpciDeviceProperty
WHvGetVpciDeviceProperty.restype = ctypes.c_int
WHvGetVpciDeviceProperty.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    ctypes.c_ulonglong,  # LogicalDeviceId : ULONGLONG
    ctypes.c_int,  # PropertyCode : WHV_VPCI_DEVICE_PROPERTY_CODE
    ctypes.POINTER(None),  # PropertyBuffer : void* out
    wintypes.DWORD,  # PropertyBufferSizeInBytes : DWORD
    ctypes.POINTER(wintypes.DWORD),  # WrittenSizeInBytes : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvGetVpciDeviceProperty = Fiddle::Function.new(
  lib['WHvGetVpciDeviceProperty'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
    -Fiddle::TYPE_LONG_LONG,  # LogicalDeviceId : ULONGLONG
    Fiddle::TYPE_INT,  # PropertyCode : WHV_VPCI_DEVICE_PROPERTY_CODE
    Fiddle::TYPE_VOIDP,  # PropertyBuffer : void* out
    -Fiddle::TYPE_INT,  # PropertyBufferSizeInBytes : DWORD
    Fiddle::TYPE_VOIDP,  # WrittenSizeInBytes : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvGetVpciDeviceProperty(
        Partition: isize,  // WHV_PARTITION_HANDLE
        LogicalDeviceId: u64,  // ULONGLONG
        PropertyCode: i32,  // WHV_VPCI_DEVICE_PROPERTY_CODE
        PropertyBuffer: *mut (),  // void* out
        PropertyBufferSizeInBytes: u32,  // DWORD
        WrittenSizeInBytes: *mut u32  // DWORD* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvGetVpciDeviceProperty(IntPtr Partition, ulong LogicalDeviceId, int PropertyCode, IntPtr PropertyBuffer, uint PropertyBufferSizeInBytes, IntPtr WrittenSizeInBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvGetVpciDeviceProperty' -Namespace Win32 -PassThru
# $api::WHvGetVpciDeviceProperty(Partition, LogicalDeviceId, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
#uselib "WinHvPlatform.dll"
#func global WHvGetVpciDeviceProperty "WHvGetVpciDeviceProperty" sptr, sptr, sptr, sptr, sptr, sptr
; WHvGetVpciDeviceProperty Partition, LogicalDeviceId, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, varptr(WrittenSizeInBytes)   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; LogicalDeviceId : ULONGLONG -> "sptr"
; PropertyCode : WHV_VPCI_DEVICE_PROPERTY_CODE -> "sptr"
; PropertyBuffer : void* out -> "sptr"
; PropertyBufferSizeInBytes : DWORD -> "sptr"
; WrittenSizeInBytes : DWORD* optional, out -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WinHvPlatform.dll"
#cfunc global WHvGetVpciDeviceProperty "WHvGetVpciDeviceProperty" sptr, int64, int, sptr, int, var
; res = WHvGetVpciDeviceProperty(Partition, LogicalDeviceId, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; LogicalDeviceId : ULONGLONG -> "int64"
; PropertyCode : WHV_VPCI_DEVICE_PROPERTY_CODE -> "int"
; PropertyBuffer : void* out -> "sptr"
; PropertyBufferSizeInBytes : DWORD -> "int"
; WrittenSizeInBytes : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
出力引数:
; HRESULT WHvGetVpciDeviceProperty(WHV_PARTITION_HANDLE Partition, ULONGLONG LogicalDeviceId, WHV_VPCI_DEVICE_PROPERTY_CODE PropertyCode, void* PropertyBuffer, DWORD PropertyBufferSizeInBytes, DWORD* WrittenSizeInBytes)
#uselib "WinHvPlatform.dll"
#cfunc global WHvGetVpciDeviceProperty "WHvGetVpciDeviceProperty" intptr, int64, int, intptr, int, var
; res = WHvGetVpciDeviceProperty(Partition, LogicalDeviceId, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; LogicalDeviceId : ULONGLONG -> "int64"
; PropertyCode : WHV_VPCI_DEVICE_PROPERTY_CODE -> "int"
; PropertyBuffer : void* out -> "intptr"
; PropertyBufferSizeInBytes : DWORD -> "int"
; WrittenSizeInBytes : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvGetVpciDeviceProperty = winhvplatform.NewProc("WHvGetVpciDeviceProperty")
)

// Partition (WHV_PARTITION_HANDLE), LogicalDeviceId (ULONGLONG), PropertyCode (WHV_VPCI_DEVICE_PROPERTY_CODE), PropertyBuffer (void* out), PropertyBufferSizeInBytes (DWORD), WrittenSizeInBytes (DWORD* optional, out)
r1, _, err := procWHvGetVpciDeviceProperty.Call(
	uintptr(Partition),
	uintptr(LogicalDeviceId),
	uintptr(PropertyCode),
	uintptr(PropertyBuffer),
	uintptr(PropertyBufferSizeInBytes),
	uintptr(WrittenSizeInBytes),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function WHvGetVpciDeviceProperty(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  LogicalDeviceId: UInt64;   // ULONGLONG
  PropertyCode: Integer;   // WHV_VPCI_DEVICE_PROPERTY_CODE
  PropertyBuffer: Pointer;   // void* out
  PropertyBufferSizeInBytes: DWORD;   // DWORD
  WrittenSizeInBytes: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvGetVpciDeviceProperty';
result := DllCall("WinHvPlatform\WHvGetVpciDeviceProperty"
    , "Ptr", Partition   ; WHV_PARTITION_HANDLE
    , "Int64", LogicalDeviceId   ; ULONGLONG
    , "Int", PropertyCode   ; WHV_VPCI_DEVICE_PROPERTY_CODE
    , "Ptr", PropertyBuffer   ; void* out
    , "UInt", PropertyBufferSizeInBytes   ; DWORD
    , "Ptr", WrittenSizeInBytes   ; DWORD* optional, out
    , "Int")   ; return: HRESULT
●WHvGetVpciDeviceProperty(Partition, LogicalDeviceId, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes) = DLL("WinHvPlatform.dll", "int WHvGetVpciDeviceProperty(int, qword, int, void*, dword, void*)")
# 呼び出し: WHvGetVpciDeviceProperty(Partition, LogicalDeviceId, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
# Partition : WHV_PARTITION_HANDLE -> "int"
# LogicalDeviceId : ULONGLONG -> "qword"
# PropertyCode : WHV_VPCI_DEVICE_PROPERTY_CODE -> "int"
# PropertyBuffer : void* out -> "void*"
# PropertyBufferSizeInBytes : DWORD -> "dword"
# WrittenSizeInBytes : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。