ホーム › System.Hypervisor › WHvGetPartitionProperty
WHvGetPartitionProperty
関数パーティションのプロパティ値を取得する。
シグネチャ
// WinHvPlatform.dll
#include <windows.h>
HRESULT WHvGetPartitionProperty(
WHV_PARTITION_HANDLE Partition,
WHV_PARTITION_PROPERTY_CODE PropertyCode,
void* PropertyBuffer,
DWORD PropertyBufferSizeInBytes,
DWORD* WrittenSizeInBytes // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| Partition | WHV_PARTITION_HANDLE | in |
| PropertyCode | WHV_PARTITION_PROPERTY_CODE | in |
| PropertyBuffer | void* | out |
| PropertyBufferSizeInBytes | DWORD | in |
| WrittenSizeInBytes | DWORD* | outoptional |
戻り値の型: 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 方式にも切替可。#uselib "WinHvPlatform.dll" #cfunc global WHvGetPartitionProperty "WHvGetPartitionProperty" sptr, int, sptr, int, sptr ; res = WHvGetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, varptr(WrittenSizeInBytes)) ; Partition : WHV_PARTITION_HANDLE -> "sptr" ; PropertyCode : WHV_PARTITION_PROPERTY_CODE -> "int" ; PropertyBuffer : void* out -> "sptr" ; PropertyBufferSizeInBytes : DWORD -> "int" ; WrittenSizeInBytes : DWORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr ; res = WHvGetPartitionProperty(Partition, PropertyCode, PropertyBuffer, PropertyBufferSizeInBytes, varptr(WrittenSizeInBytes)) ; Partition : WHV_PARTITION_HANDLE -> "intptr" ; PropertyCode : WHV_PARTITION_PROPERTY_CODE -> "int" ; PropertyBuffer : void* out -> "intptr" ; PropertyBufferSizeInBytes : DWORD -> "int" ; WrittenSizeInBytes : DWORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。