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作成時に適用するプロパティ配列へのポインタ。NULL可。
PropertyCountDWORDinProperties配列に含まれるプロパティ数。

戻り値の型: 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)。
const std = @import("std");

extern "winhvplatform" fn WHvCreateVirtualProcessor2(
    Partition: isize, // WHV_PARTITION_HANDLE
    VpIndex: u32, // DWORD
    Properties: [*c]WHV_VIRTUAL_PROCESSOR_PROPERTY, // WHV_VIRTUAL_PROCESSOR_PROPERTY*
    PropertyCount: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc WHvCreateVirtualProcessor2(
    Partition: int,  # WHV_PARTITION_HANDLE
    VpIndex: uint32,  # DWORD
    Properties: ptr WHV_VIRTUAL_PROCESSOR_PROPERTY,  # WHV_VIRTUAL_PROCESSOR_PROPERTY*
    PropertyCount: uint32  # DWORD
): int32 {.importc: "WHvCreateVirtualProcessor2", stdcall, dynlib: "WinHvPlatform.dll".}
pragma(lib, "winhvplatform");
extern(Windows)
int WHvCreateVirtualProcessor2(
    ptrdiff_t Partition,   // WHV_PARTITION_HANDLE
    uint VpIndex,   // DWORD
    WHV_VIRTUAL_PROCESSOR_PROPERTY* Properties,   // WHV_VIRTUAL_PROCESSOR_PROPERTY*
    uint PropertyCount   // DWORD
);
ccall((:WHvCreateVirtualProcessor2, "WinHvPlatform.dll"), stdcall, Int32,
      (Int, UInt32, Ptr{WHV_VIRTUAL_PROCESSOR_PROPERTY}, UInt32),
      Partition, VpIndex, Properties, PropertyCount)
# Partition : WHV_PARTITION_HANDLE -> Int
# VpIndex : DWORD -> UInt32
# Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> Ptr{WHV_VIRTUAL_PROCESSOR_PROPERTY}
# PropertyCount : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WHvCreateVirtualProcessor2(
    intptr_t Partition,
    uint32_t VpIndex,
    void* Properties,
    uint32_t PropertyCount);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvCreateVirtualProcessor2(Partition, VpIndex, Properties, PropertyCount)
-- Partition : WHV_PARTITION_HANDLE
-- VpIndex : DWORD
-- Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY*
-- PropertyCount : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvCreateVirtualProcessor2 = lib.func('__stdcall', 'WHvCreateVirtualProcessor2', 'int32_t', ['intptr_t', 'uint32_t', 'void *', 'uint32_t']);
// WHvCreateVirtualProcessor2(Partition, VpIndex, Properties, PropertyCount)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// VpIndex : DWORD -> 'uint32_t'
// Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> 'void *'
// PropertyCount : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WinHvPlatform.dll", {
  WHvCreateVirtualProcessor2: { parameters: ["isize", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.WHvCreateVirtualProcessor2(Partition, VpIndex, Properties, PropertyCount)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// VpIndex : DWORD -> "u32"
// Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> "pointer"
// PropertyCount : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WHvCreateVirtualProcessor2(
    intptr_t Partition,
    uint32_t VpIndex,
    void* Properties,
    uint32_t PropertyCount);
C, "WinHvPlatform.dll");
// $ffi->WHvCreateVirtualProcessor2(Partition, VpIndex, Properties, PropertyCount);
// Partition : WHV_PARTITION_HANDLE
// VpIndex : DWORD
// Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY*
// PropertyCount : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Winhvplatform extends StdCallLibrary {
    Winhvplatform INSTANCE = Native.load("winhvplatform", Winhvplatform.class);
    int WHvCreateVirtualProcessor2(
        long Partition,   // WHV_PARTITION_HANDLE
        int VpIndex,   // DWORD
        Pointer Properties,   // WHV_VIRTUAL_PROCESSOR_PROPERTY*
        int PropertyCount   // DWORD
    );
}
@[Link("winhvplatform")]
lib LibWinHvPlatform
  fun WHvCreateVirtualProcessor2 = WHvCreateVirtualProcessor2(
    Partition : LibC::SSizeT,   # WHV_PARTITION_HANDLE
    VpIndex : UInt32,   # DWORD
    Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY*,   # WHV_VIRTUAL_PROCESSOR_PROPERTY*
    PropertyCount : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WHvCreateVirtualProcessor2Native = Int32 Function(IntPtr, Uint32, Pointer<Void>, Uint32);
typedef WHvCreateVirtualProcessor2Dart = int Function(int, int, Pointer<Void>, int);
final WHvCreateVirtualProcessor2 = DynamicLibrary.open('WinHvPlatform.dll')
    .lookupFunction<WHvCreateVirtualProcessor2Native, WHvCreateVirtualProcessor2Dart>('WHvCreateVirtualProcessor2');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// VpIndex : DWORD -> Uint32
// Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> Pointer<Void>
// PropertyCount : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WHvCreateVirtualProcessor2"
  c_WHvCreateVirtualProcessor2 :: CIntPtr -> Word32 -> Ptr () -> Word32 -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- VpIndex : DWORD -> Word32
-- Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> Ptr ()
-- PropertyCount : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whvcreatevirtualprocessor2 =
  foreign "WHvCreateVirtualProcessor2"
    (intptr_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* VpIndex : DWORD -> uint32_t *)
(* Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> (ptr void) *)
(* PropertyCount : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winhvplatform (t "WinHvPlatform.dll"))
(cffi:use-foreign-library winhvplatform)

(cffi:defcfun ("WHvCreateVirtualProcessor2" whv-create-virtual-processor2 :convention :stdcall) :int32
  (partition :int64)   ; WHV_PARTITION_HANDLE
  (vp-index :uint32)   ; DWORD
  (properties :pointer)   ; WHV_VIRTUAL_PROCESSOR_PROPERTY*
  (property-count :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvCreateVirtualProcessor2 = Win32::API::More->new('WinHvPlatform',
    'int WHvCreateVirtualProcessor2(LPARAM Partition, DWORD VpIndex, LPVOID Properties, DWORD PropertyCount)');
# my $ret = $WHvCreateVirtualProcessor2->Call($Partition, $VpIndex, $Properties, $PropertyCount);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# VpIndex : DWORD -> DWORD
# Properties : WHV_VIRTUAL_PROCESSOR_PROPERTY* -> LPVOID
# PropertyCount : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型