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

WHvGetPartitionProperty

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

シグネチャ

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

HRESULT WHvGetPartitionProperty(
    WHV_PARTITION_HANDLE Partition,
    WHV_PARTITION_PROPERTY_CODE PropertyCode,
    void* PropertyBuffer,
    DWORD PropertyBufferSizeInBytes,
    DWORD* WrittenSizeInBytes   // optional
);

パラメーター

名前方向説明
PartitionWHV_PARTITION_HANDLEinプロパティを取得する対象パーティションハンドル。
PropertyCodeWHV_PARTITION_PROPERTY_CODEin取得するプロパティを指定する列挙コード。
PropertyBuffervoid*outプロパティ値を受け取る出力バッファへのポインタ。
PropertyBufferSizeInBytesDWORDin出力バッファのサイズをバイト単位で指定する。
WrittenSizeInBytesDWORD*outoptional実際に書き込まれたバイト数を受け取るポインタ。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

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

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

var (
	winhvplatform = windows.NewLazySystemDLL("WinHvPlatform.dll")
	procWHvGetPartitionProperty = winhvplatform.NewProc("WHvGetPartitionProperty")
)

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

extern "winhvplatform" fn WHvGetPartitionProperty(
    Partition: isize, // WHV_PARTITION_HANDLE
    PropertyCode: i32, // WHV_PARTITION_PROPERTY_CODE
    PropertyBuffer: ?*anyopaque, // void* out
    PropertyBufferSizeInBytes: u32, // DWORD
    WrittenSizeInBytes: [*c]u32 // DWORD* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc WHvGetPartitionProperty(
    Partition: int,  # WHV_PARTITION_HANDLE
    PropertyCode: int32,  # WHV_PARTITION_PROPERTY_CODE
    PropertyBuffer: pointer,  # void* out
    PropertyBufferSizeInBytes: uint32,  # DWORD
    WrittenSizeInBytes: ptr uint32  # DWORD* optional, out
): int32 {.importc: "WHvGetPartitionProperty", stdcall, dynlib: "WinHvPlatform.dll".}
pragma(lib, "winhvplatform");
extern(Windows)
int WHvGetPartitionProperty(
    ptrdiff_t Partition,   // WHV_PARTITION_HANDLE
    int PropertyCode,   // WHV_PARTITION_PROPERTY_CODE
    void* PropertyBuffer,   // void* out
    uint PropertyBufferSizeInBytes,   // DWORD
    uint* WrittenSizeInBytes   // DWORD* optional, out
);
ccall((:WHvGetPartitionProperty, "WinHvPlatform.dll"), stdcall, Int32,
      (Int, Int32, Ptr{Cvoid}, UInt32, Ptr{UInt32}),
      Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
# Partition : WHV_PARTITION_HANDLE -> Int
# PropertyCode : WHV_PARTITION_PROPERTY_CODE -> Int32
# PropertyBuffer : void* out -> Ptr{Cvoid}
# PropertyBufferSizeInBytes : DWORD -> UInt32
# WrittenSizeInBytes : DWORD* optional, out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t WHvGetPartitionProperty(
    intptr_t Partition,
    int32_t PropertyCode,
    void* PropertyBuffer,
    uint32_t PropertyBufferSizeInBytes,
    uint32_t* WrittenSizeInBytes);
]]
local winhvplatform = ffi.load("winhvplatform")
-- winhvplatform.WHvGetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
-- Partition : WHV_PARTITION_HANDLE
-- PropertyCode : WHV_PARTITION_PROPERTY_CODE
-- PropertyBuffer : void* out
-- PropertyBufferSizeInBytes : DWORD
-- WrittenSizeInBytes : DWORD* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WinHvPlatform.dll');
const WHvGetPartitionProperty = lib.func('__stdcall', 'WHvGetPartitionProperty', 'int32_t', ['intptr_t', 'int32_t', 'void *', 'uint32_t', 'uint32_t *']);
// WHvGetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
// Partition : WHV_PARTITION_HANDLE -> 'intptr_t'
// PropertyCode : WHV_PARTITION_PROPERTY_CODE -> 'int32_t'
// PropertyBuffer : void* out -> 'void *'
// PropertyBufferSizeInBytes : DWORD -> 'uint32_t'
// WrittenSizeInBytes : DWORD* optional, out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WinHvPlatform.dll", {
  WHvGetPartitionProperty: { parameters: ["isize", "i32", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.WHvGetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes)
// Partition : WHV_PARTITION_HANDLE -> "isize"
// PropertyCode : WHV_PARTITION_PROPERTY_CODE -> "i32"
// PropertyBuffer : void* out -> "pointer"
// PropertyBufferSizeInBytes : DWORD -> "u32"
// WrittenSizeInBytes : DWORD* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t WHvGetPartitionProperty(
    intptr_t Partition,
    int32_t PropertyCode,
    void* PropertyBuffer,
    uint32_t PropertyBufferSizeInBytes,
    uint32_t* WrittenSizeInBytes);
C, "WinHvPlatform.dll");
// $ffi->WHvGetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, WrittenSizeInBytes);
// Partition : WHV_PARTITION_HANDLE
// PropertyCode : WHV_PARTITION_PROPERTY_CODE
// PropertyBuffer : void* out
// PropertyBufferSizeInBytes : DWORD
// WrittenSizeInBytes : DWORD* optional, out
// 構造体/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 WHvGetPartitionProperty(
        long Partition,   // WHV_PARTITION_HANDLE
        int PropertyCode,   // WHV_PARTITION_PROPERTY_CODE
        Pointer PropertyBuffer,   // void* out
        int PropertyBufferSizeInBytes,   // DWORD
        IntByReference WrittenSizeInBytes   // DWORD* optional, out
    );
}
@[Link("winhvplatform")]
lib LibWinHvPlatform
  fun WHvGetPartitionProperty = WHvGetPartitionProperty(
    Partition : LibC::SSizeT,   # WHV_PARTITION_HANDLE
    PropertyCode : Int32,   # WHV_PARTITION_PROPERTY_CODE
    PropertyBuffer : Void*,   # void* out
    PropertyBufferSizeInBytes : UInt32,   # DWORD
    WrittenSizeInBytes : UInt32*   # DWORD* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WHvGetPartitionPropertyNative = Int32 Function(IntPtr, Int32, Pointer<Void>, Uint32, Pointer<Uint32>);
typedef WHvGetPartitionPropertyDart = int Function(int, int, Pointer<Void>, int, Pointer<Uint32>);
final WHvGetPartitionProperty = DynamicLibrary.open('WinHvPlatform.dll')
    .lookupFunction<WHvGetPartitionPropertyNative, WHvGetPartitionPropertyDart>('WHvGetPartitionProperty');
// Partition : WHV_PARTITION_HANDLE -> IntPtr
// PropertyCode : WHV_PARTITION_PROPERTY_CODE -> Int32
// PropertyBuffer : void* out -> Pointer<Void>
// PropertyBufferSizeInBytes : DWORD -> Uint32
// WrittenSizeInBytes : DWORD* optional, out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function WHvGetPartitionProperty(
  Partition: NativeInt;   // WHV_PARTITION_HANDLE
  PropertyCode: Integer;   // WHV_PARTITION_PROPERTY_CODE
  PropertyBuffer: Pointer;   // void* out
  PropertyBufferSizeInBytes: DWORD;   // DWORD
  WrittenSizeInBytes: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'WinHvPlatform.dll' name 'WHvGetPartitionProperty';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let whvgetpartitionproperty =
  foreign "WHvGetPartitionProperty"
    (intptr_t @-> int32_t @-> (ptr void) @-> uint32_t @-> (ptr uint32_t) @-> returning int32_t)
(* Partition : WHV_PARTITION_HANDLE -> intptr_t *)
(* PropertyCode : WHV_PARTITION_PROPERTY_CODE -> int32_t *)
(* PropertyBuffer : void* out -> (ptr void) *)
(* PropertyBufferSizeInBytes : DWORD -> uint32_t *)
(* WrittenSizeInBytes : DWORD* optional, out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winhvplatform (t "WinHvPlatform.dll"))
(cffi:use-foreign-library winhvplatform)

(cffi:defcfun ("WHvGetPartitionProperty" whv-get-partition-property :convention :stdcall) :int32
  (partition :int64)   ; WHV_PARTITION_HANDLE
  (property-code :int32)   ; WHV_PARTITION_PROPERTY_CODE
  (property-buffer :pointer)   ; void* out
  (property-buffer-size-in-bytes :uint32)   ; DWORD
  (written-size-in-bytes :pointer))   ; DWORD* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WHvGetPartitionProperty = Win32::API::More->new('WinHvPlatform',
    'int WHvGetPartitionProperty(LPARAM Partition, int PropertyCode, LPVOID PropertyBuffer, DWORD PropertyBufferSizeInBytes, LPVOID WrittenSizeInBytes)');
# my $ret = $WHvGetPartitionProperty->Call($Partition, $PropertyCode, $PropertyBuffer, $PropertyBufferSizeInBytes, $WrittenSizeInBytes);
# Partition : WHV_PARTITION_HANDLE -> LPARAM
# PropertyCode : WHV_PARTITION_PROPERTY_CODE -> int
# PropertyBuffer : void* out -> LPVOID
# PropertyBufferSizeInBytes : DWORD -> DWORD
# WrittenSizeInBytes : DWORD* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型