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

WHvSetPartitionProperty

関数
パーティションのプロパティ値を設定する。
DLLWinHvPlatform.dll呼出規約winapi

シグネチャ

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

HRESULT WHvSetPartitionProperty(
    WHV_PARTITION_HANDLE Partition,
    WHV_PARTITION_PROPERTY_CODE PropertyCode,
    const void* PropertyBuffer,
    DWORD PropertyBufferSizeInBytes
);

パラメーター

名前方向
PartitionWHV_PARTITION_HANDLEin
PropertyCodeWHV_PARTITION_PROPERTY_CODEin
PropertyBuffervoid*in
PropertyBufferSizeInBytesDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

WHvSetPartitionProperty = ctypes.windll.winhvplatform.WHvSetPartitionProperty
WHvSetPartitionProperty.restype = ctypes.c_int
WHvSetPartitionProperty.argtypes = [
    ctypes.c_ssize_t,  # Partition : WHV_PARTITION_HANDLE
    ctypes.c_int,  # PropertyCode : WHV_PARTITION_PROPERTY_CODE
    ctypes.POINTER(None),  # PropertyBuffer : void*
    wintypes.DWORD,  # PropertyBufferSizeInBytes : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WinHvPlatform.dll')
WHvSetPartitionProperty = Fiddle::Function.new(
  lib['WHvSetPartitionProperty'],
  [
    Fiddle::TYPE_INTPTR_T,  # Partition : WHV_PARTITION_HANDLE
    Fiddle::TYPE_INT,  # PropertyCode : WHV_PARTITION_PROPERTY_CODE
    Fiddle::TYPE_VOIDP,  # PropertyBuffer : void*
    -Fiddle::TYPE_INT,  # PropertyBufferSizeInBytes : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhvplatform")]
extern "system" {
    fn WHvSetPartitionProperty(
        Partition: isize,  // WHV_PARTITION_HANDLE
        PropertyCode: i32,  // WHV_PARTITION_PROPERTY_CODE
        PropertyBuffer: *const (),  // void*
        PropertyBufferSizeInBytes: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WinHvPlatform.dll")]
public static extern int WHvSetPartitionProperty(IntPtr Partition, int PropertyCode, IntPtr PropertyBuffer, uint PropertyBufferSizeInBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WinHvPlatform_WHvSetPartitionProperty' -Namespace Win32 -PassThru
# $api::WHvSetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes)
#uselib "WinHvPlatform.dll"
#func global WHvSetPartitionProperty "WHvSetPartitionProperty" sptr, sptr, sptr, sptr
; WHvSetPartitionProperty Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes   ; 戻り値は stat
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; PropertyCode : WHV_PARTITION_PROPERTY_CODE -> "sptr"
; PropertyBuffer : void* -> "sptr"
; PropertyBufferSizeInBytes : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WinHvPlatform.dll"
#cfunc global WHvSetPartitionProperty "WHvSetPartitionProperty" sptr, int, sptr, int
; res = WHvSetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes)
; Partition : WHV_PARTITION_HANDLE -> "sptr"
; PropertyCode : WHV_PARTITION_PROPERTY_CODE -> "int"
; PropertyBuffer : void* -> "sptr"
; PropertyBufferSizeInBytes : DWORD -> "int"
; HRESULT WHvSetPartitionProperty(WHV_PARTITION_HANDLE Partition, WHV_PARTITION_PROPERTY_CODE PropertyCode, void* PropertyBuffer, DWORD PropertyBufferSizeInBytes)
#uselib "WinHvPlatform.dll"
#cfunc global WHvSetPartitionProperty "WHvSetPartitionProperty" intptr, int, intptr, int
; res = WHvSetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes)
; Partition : WHV_PARTITION_HANDLE -> "intptr"
; PropertyCode : WHV_PARTITION_PROPERTY_CODE -> "int"
; PropertyBuffer : void* -> "intptr"
; PropertyBufferSizeInBytes : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvSetPartitionProperty = winhvplatform.NewProc("WHvSetPartitionProperty")
)

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