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

WHvCreateVpciDevice

関数
パーティションに仮想PCIデバイスを作成する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvCreateVpciDevice(
    WHV_PARTITION_HANDLE Partition,
    ULONGLONG LogicalDeviceId,
    HANDLE VpciResource,
    WHV_CREATE_VPCI_DEVICE_FLAGS Flags,
    HANDLE NotificationEventHandle   // optional
);

パラメーター

名前方向
PartitionWHV_PARTITION_HANDLEin
LogicalDeviceIdULONGLONGin
VpciResourceHANDLEin
FlagsWHV_CREATE_VPCI_DEVICE_FLAGSin
NotificationEventHandleHANDLEinoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WHvCreateVpciDevice(
    WHV_PARTITION_HANDLE Partition,
    ULONGLONG LogicalDeviceId,
    HANDLE VpciResource,
    WHV_CREATE_VPCI_DEVICE_FLAGS Flags,
    HANDLE NotificationEventHandle   // optional
);
[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvCreateVpciDevice(
    IntPtr Partition,   // WHV_PARTITION_HANDLE
    ulong LogicalDeviceId,   // ULONGLONG
    IntPtr VpciResource,   // HANDLE
    int Flags,   // WHV_CREATE_VPCI_DEVICE_FLAGS
    IntPtr NotificationEventHandle   // HANDLE optional
);
<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvCreateVpciDevice(
    Partition As IntPtr,   ' WHV_PARTITION_HANDLE
    LogicalDeviceId As ULong,   ' ULONGLONG
    VpciResource As IntPtr,   ' HANDLE
    Flags As Integer,   ' WHV_CREATE_VPCI_DEVICE_FLAGS
    NotificationEventHandle As IntPtr   ' HANDLE optional
) As Integer
End Function
' Partition : WHV_PARTITION_HANDLE
' LogicalDeviceId : ULONGLONG
' VpciResource : HANDLE
' Flags : WHV_CREATE_VPCI_DEVICE_FLAGS
' NotificationEventHandle : HANDLE optional
Declare PtrSafe Function WHvCreateVpciDevice Lib "winhvplatform" ( _
    ByVal Partition As LongPtr, _
    ByVal LogicalDeviceId As LongLong, _
    ByVal VpciResource As LongPtr, _
    ByVal Flags As Long, _
    ByVal NotificationEventHandle As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvCreateVpciDevice = ctypes.windll.winhvplatform.WHvCreateVpciDevice
WHvCreateVpciDevice.restype = ctypes.c_int
WHvCreateVpciDevice.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    ctypes.c_ulonglong,  # LogicalDeviceId : ULONGLONG
    wintypes.HANDLE,  # VpciResource : HANDLE
    ctypes.c_int,  # Flags : WHV_CREATE_VPCI_DEVICE_FLAGS
    wintypes.HANDLE,  # NotificationEventHandle : HANDLE optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvCreateVpciDevice = Fiddle::Function.new(
  lib['WHvCreateVpciDevice'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
    -Fiddle::TYPE_LONG_LONG,  # LogicalDeviceId : ULONGLONG
    Fiddle::TYPE_VOIDP,  # VpciResource : HANDLE
    Fiddle::TYPE_INT,  # Flags : WHV_CREATE_VPCI_DEVICE_FLAGS
    Fiddle::TYPE_VOIDP,  # NotificationEventHandle : HANDLE optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvCreateVpciDevice(
        Partition: isize,  // WHV_PARTITION_HANDLE
        LogicalDeviceId: u64,  // ULONGLONG
        VpciResource: *mut core::ffi::c_void,  // HANDLE
        Flags: i32,  // WHV_CREATE_VPCI_DEVICE_FLAGS
        NotificationEventHandle: *mut core::ffi::c_void  // HANDLE optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvCreateVpciDevice(IntPtr Partition, ulong LogicalDeviceId, IntPtr VpciResource, int Flags, IntPtr NotificationEventHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvCreateVpciDevice' -Namespace Win32 -PassThru
# $api::WHvCreateVpciDevice(Partition, LogicalDeviceId, VpciResource, Flags, NotificationEventHandle)
#uselib "WinHvPlatform.dll"
#func global WHvCreateVpciDevice "WHvCreateVpciDevice" sptr, sptr, sptr, sptr, sptr
; WHvCreateVpciDevice Partition, LogicalDeviceId, VpciResource, Flags, NotificationEventHandle   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; LogicalDeviceId : ULONGLONG -> "sptr"
; VpciResource : HANDLE -> "sptr"
; Flags : WHV_CREATE_VPCI_DEVICE_FLAGS -> "sptr"
; NotificationEventHandle : HANDLE optional -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WinHvPlatform.dll"
#cfunc global WHvCreateVpciDevice "WHvCreateVpciDevice" sptr, int64, sptr, int, sptr
; res = WHvCreateVpciDevice(Partition, LogicalDeviceId, VpciResource, Flags, NotificationEventHandle)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; LogicalDeviceId : ULONGLONG -> "int64"
; VpciResource : HANDLE -> "sptr"
; Flags : WHV_CREATE_VPCI_DEVICE_FLAGS -> "int"
; NotificationEventHandle : HANDLE optional -> "sptr"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; HRESULT WHvCreateVpciDevice(WHV_PARTITION_HANDLE Partition, ULONGLONG LogicalDeviceId, HANDLE VpciResource, WHV_CREATE_VPCI_DEVICE_FLAGS Flags, HANDLE NotificationEventHandle)
#uselib "WinHvPlatform.dll"
#cfunc global WHvCreateVpciDevice "WHvCreateVpciDevice" intptr, int64, intptr, int, intptr
; res = WHvCreateVpciDevice(Partition, LogicalDeviceId, VpciResource, Flags, NotificationEventHandle)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; LogicalDeviceId : ULONGLONG -> "int64"
; VpciResource : HANDLE -> "intptr"
; Flags : WHV_CREATE_VPCI_DEVICE_FLAGS -> "int"
; NotificationEventHandle : HANDLE optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvCreateVpciDevice = winhvplatform.NewProc("WHvCreateVpciDevice")
)

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