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

WHvCreateVirtualProcessor2

関数
プロパティ指定で仮想プロセッサを作成する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvCreateVirtualProcessor2(
    WHV_PARTITION_HANDLE Partition,
    DWORD VpIndex,
    const WHV_VIRTUAL_PROCESSOR_PROPERTY* Properties,
    DWORD PropertyCount
);

パラメーター

名前方向
PartitionWHV_PARTITION_HANDLEin
VpIndexDWORDin
PropertiesWHV_VIRTUAL_PROCESSOR_PROPERTY*in
PropertyCountDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT WHvCreateVirtualProcessor2(
    WHV_PARTITION_HANDLE Partition,
    DWORD VpIndex,
    const WHV_VIRTUAL_PROCESSOR_PROPERTY* Properties,
    DWORD PropertyCount
);
[DllImport("WinHvPlatform.dll", ExactSpelling = true)]
static extern int WHvCreateVirtualProcessor2(
    IntPtr Partition,   // WHV_PARTITION_HANDLE
    uint VpIndex,   // DWORD
    IntPtr Properties,   // WHV_VIRTUAL_PROCESSOR_PROPERTY*
    uint PropertyCount   // DWORD
);
<DllImport("WinHvPlatform.dll", ExactSpelling:=True)>
Public Shared Function WHvCreateVirtualProcessor2(
    Partition As IntPtr,   ' WHV_PARTITION_HANDLE
    VpIndex As UInteger,   ' DWORD
    Properties As IntPtr,   ' WHV_VIRTUAL_PROCESSOR_PROPERTY*
    PropertyCount As UInteger   ' DWORD
) As Integer
End Function
' Partition : WHV_PARTITION_HANDLE
' VpIndex : DWORD
' Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY*
' PropertyCount : DWORD
Declare PtrSafe Function WHvCreateVirtualProcessor2 Lib "winhvplatform" ( _
    ByVal Partition As LongPtr, _
    ByVal VpIndex As Long, _
    ByVal Properties As LongPtr, _
    ByVal PropertyCount As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WHvCreateVirtualProcessor2 = ctypes.windll.winhvplatform.WHvCreateVirtualProcessor2
WHvCreateVirtualProcessor2.restype = ctypes.c_int
WHvCreateVirtualProcessor2.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    wintypes.DWORD,  # VpIndex : DWORD
    ctypes.c_void_p,  # Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY*
    wintypes.DWORD,  # PropertyCount : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvCreateVirtualProcessor2 = Fiddle::Function.new(
  lib['WHvCreateVirtualProcessor2'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
    -Fiddle::TYPE_INT,  # VpIndex : DWORD
    Fiddle::TYPE_VOIDP,  # Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY*
    -Fiddle::TYPE_INT,  # PropertyCount : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvCreateVirtualProcessor2(
        Partition: isize,  // WHV_PARTITION_HANDLE
        VpIndex: u32,  // DWORD
        Properties: *const WHV_VIRTUAL_PROCESSOR_PROPERTY,  // WHV_VIRTUAL_PROCESSOR_PROPERTY*
        PropertyCount: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvCreateVirtualProcessor2(IntPtr Partition, uint VpIndex, IntPtr Properties, uint PropertyCount);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvCreateVirtualProcessor2' -Namespace Win32 -PassThru
# $api::WHvCreateVirtualProcessor2(Partition, VpIndex, Properties, PropertyCount)
#uselib "WinHvPlatform.dll"
#func global WHvCreateVirtualProcessor2 "WHvCreateVirtualProcessor2" sptr, sptr, sptr, sptr
; WHvCreateVirtualProcessor2 Partition, VpIndex, varptr(Properties), PropertyCount   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; VpIndex : DWORD -> "sptr"
; Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> "sptr"
; PropertyCount : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WinHvPlatform.dll"
#cfunc global WHvCreateVirtualProcessor2 "WHvCreateVirtualProcessor2" sptr, int, var, int
; res = WHvCreateVirtualProcessor2(Partition, VpIndex, Properties, PropertyCount)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; VpIndex : DWORD -> "int"
; Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> "var"
; PropertyCount : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT WHvCreateVirtualProcessor2(WHV_PARTITION_HANDLE Partition, DWORD VpIndex, WHV_VIRTUAL_PROCESSOR_PROPERTY* Properties, DWORD PropertyCount)
#uselib "WinHvPlatform.dll"
#cfunc global WHvCreateVirtualProcessor2 "WHvCreateVirtualProcessor2" intptr, int, var, int
; res = WHvCreateVirtualProcessor2(Partition, VpIndex, Properties, PropertyCount)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; VpIndex : DWORD -> "int"
; Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> "var"
; PropertyCount : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvCreateVirtualProcessor2 = winhvplatform.NewProc("WHvCreateVirtualProcessor2")
)

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