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