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)。
const std = @import("std");

extern "winhvplatform" fn WHvSetPartitionProperty(
    Partition: isize, // WHV_PARTITION_HANDLE
    PropertyCode: i32, // WHV_PARTITION_PROPERTY_CODE
    PropertyBuffer: ?*anyopaque, // void*
    PropertyBufferSizeInBytes: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc WHvSetPartitionProperty(
    Partition: int,  # WHV_PARTITION_HANDLE
    PropertyCode: int32,  # WHV_PARTITION_PROPERTY_CODE
    PropertyBuffer: pointer,  # void*
    PropertyBufferSizeInBytes: uint32  # DWORD
): int32 {.importc: "WHvSetPartitionProperty", stdcall, dynlib: "WinHvPlatform.dll".}
pragma(lib, "winhvplatform");
extern(Windows)
int WHvSetPartitionProperty(
    ptrdiff_t Partition,   // WHV_PARTITION_HANDLE
    int PropertyCode,   // WHV_PARTITION_PROPERTY_CODE
    void* PropertyBuffer,   // void*
    uint PropertyBufferSizeInBytes   // DWORD
);
ccall((:WHvSetPartitionProperty, "WinHvPlatform.dll"), stdcall, Int32,
      (Int, Int32, Ptr{Cvoid}, UInt32),
      Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes)
# Partition : WHV_PARTITION_HANDLE -> Int
# PropertyCode : WHV_PARTITION_PROPERTY_CODE -> Int32
# PropertyBuffer : void* -> Ptr{Cvoid}
# PropertyBufferSizeInBytes : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WHvSetPartitionProperty(
    intptr_t Partition,
    int32_t PropertyCode,
    void* PropertyBuffer,
    uint32_t PropertyBufferSizeInBytes);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvSetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes)
-- Partition : WHV_PARTITION_HANDLE
-- PropertyCode : WHV_PARTITION_PROPERTY_CODE
-- PropertyBuffer : void*
-- PropertyBufferSizeInBytes : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvSetPartitionProperty = lib.func('__stdcall', 'WHvSetPartitionProperty', 'int32_t', ['intptr_t', 'int32_t', 'void *', 'uint32_t']);
// WHvSetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// PropertyCode : WHV_PARTITION_PROPERTY_CODE -> 'int32_t'
// PropertyBuffer : void* -> 'void *'
// PropertyBufferSizeInBytes : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WinHvPlatform.dll", {
  WHvSetPartitionProperty: { parameters: ["isize", "i32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.WHvSetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// PropertyCode : WHV_PARTITION_PROPERTY_CODE -> "i32"
// PropertyBuffer : void* -> "pointer"
// PropertyBufferSizeInBytes : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WHvSetPartitionProperty(
    intptr_t Partition,
    int32_t PropertyCode,
    void* PropertyBuffer,
    uint32_t PropertyBufferSizeInBytes);
C, "WinHvPlatform.dll");
// $ffi->WHvSetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes);
// Partition : WHV_PARTITION_HANDLE
// PropertyCode : WHV_PARTITION_PROPERTY_CODE
// PropertyBuffer : void*
// PropertyBufferSizeInBytes : 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 WHvSetPartitionProperty(
        long Partition,   // WHV_PARTITION_HANDLE
        int PropertyCode,   // WHV_PARTITION_PROPERTY_CODE
        Pointer PropertyBuffer,   // void*
        int PropertyBufferSizeInBytes   // DWORD
    );
}
@[Link("winhvplatform")]
lib LibWinHvPlatform
  fun WHvSetPartitionProperty = WHvSetPartitionProperty(
    Partition : LibC::SSizeT,   # WHV_PARTITION_HANDLE
    PropertyCode : Int32,   # WHV_PARTITION_PROPERTY_CODE
    PropertyBuffer : Void*,   # void*
    PropertyBufferSizeInBytes : 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 WHvSetPartitionPropertyNative = Int32 Function(IntPtr, Int32, Pointer<Void>, Uint32);
typedef WHvSetPartitionPropertyDart = int Function(int, int, Pointer<Void>, int);
final WHvSetPartitionProperty = DynamicLibrary.open('WinHvPlatform.dll')
    .lookupFunction<WHvSetPartitionPropertyNative, WHvSetPartitionPropertyDart>('WHvSetPartitionProperty');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// PropertyCode : WHV_PARTITION_PROPERTY_CODE -> Int32
// PropertyBuffer : void* -> Pointer<Void>
// PropertyBufferSizeInBytes : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WHvSetPartitionProperty"
  c_WHvSetPartitionProperty :: CIntPtr -> Int32 -> Ptr () -> Word32 -> IO Int32
-- Partition : WHV_PARTITION_HANDLE -> CIntPtr
-- PropertyCode : WHV_PARTITION_PROPERTY_CODE -> Int32
-- PropertyBuffer : void* -> Ptr ()
-- PropertyBufferSizeInBytes : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let whvsetpartitionproperty =
  foreign "WHvSetPartitionProperty"
    (intptr_t @-> int32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* PropertyCode : WHV_PARTITION_PROPERTY_CODE -> int32_t *)
(* PropertyBuffer : void* -> (ptr void) *)
(* PropertyBufferSizeInBytes : 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 ("WHvSetPartitionProperty" whv-set-partition-property :convention :stdcall) :int32
  (partition :int64)   ; WHV_PARTITION_HANDLE
  (property-code :int32)   ; WHV_PARTITION_PROPERTY_CODE
  (property-buffer :pointer)   ; void*
  (property-buffer-size-in-bytes :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvSetPartitionProperty = Win32::API::More->new('WinHvPlatform',
    'int WHvSetPartitionProperty(LPARAM Partition, int PropertyCode, LPVOID PropertyBuffer, DWORD PropertyBufferSizeInBytes)');
# my $ret = $WHvSetPartitionProperty->Call($Partition, $PropertyCode, $PropertyBuffer, $PropertyBufferSizeInBytes);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# PropertyCode : WHV_PARTITION_PROPERTY_CODE -> int
# PropertyBuffer : void* -> LPVOID
# PropertyBufferSizeInBytes : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型