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

QueryPartitionInformation

関数
メモリパーティションの情報をクラス別に問い合わせる。
DLLapi-ms-win-core-memory-l1-1-8.dll呼出規約winapi

シグネチャ

// api-ms-win-core-memory-l1-1-8.dll
#include <windows.h>

BOOL QueryPartitionInformation(
    HANDLE Partition,
    WIN32_MEMORY_PARTITION_INFORMATION_CLASS PartitionInformationClass,
    void* PartitionInformation,
    DWORD PartitionInformationLength
);

パラメーター

名前方向
PartitionHANDLEin
PartitionInformationClassWIN32_MEMORY_PARTITION_INFORMATION_CLASSin
PartitionInformationvoid*inout
PartitionInformationLengthDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// api-ms-win-core-memory-l1-1-8.dll
#include <windows.h>

BOOL QueryPartitionInformation(
    HANDLE Partition,
    WIN32_MEMORY_PARTITION_INFORMATION_CLASS PartitionInformationClass,
    void* PartitionInformation,
    DWORD PartitionInformationLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-memory-l1-1-8.dll", ExactSpelling = true)]
static extern bool QueryPartitionInformation(
    IntPtr Partition,   // HANDLE
    int PartitionInformationClass,   // WIN32_MEMORY_PARTITION_INFORMATION_CLASS
    IntPtr PartitionInformation,   // void* in/out
    uint PartitionInformationLength   // DWORD
);
<DllImport("api-ms-win-core-memory-l1-1-8.dll", ExactSpelling:=True)>
Public Shared Function QueryPartitionInformation(
    Partition As IntPtr,   ' HANDLE
    PartitionInformationClass As Integer,   ' WIN32_MEMORY_PARTITION_INFORMATION_CLASS
    PartitionInformation As IntPtr,   ' void* in/out
    PartitionInformationLength As UInteger   ' DWORD
) As Boolean
End Function
' Partition : HANDLE
' PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS
' PartitionInformation : void* in/out
' PartitionInformationLength : DWORD
Declare PtrSafe Function QueryPartitionInformation Lib "api-ms-win-core-memory-l1-1-8" ( _
    ByVal Partition As LongPtr, _
    ByVal PartitionInformationClass As Long, _
    ByVal PartitionInformation As LongPtr, _
    ByVal PartitionInformationLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

QueryPartitionInformation = ctypes.windll.LoadLibrary("api-ms-win-core-memory-l1-1-8.dll").QueryPartitionInformation
QueryPartitionInformation.restype = wintypes.BOOL
QueryPartitionInformation.argtypes = [
    wintypes.HANDLE,  # Partition : HANDLE
    ctypes.c_int,  # PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS
    ctypes.POINTER(None),  # PartitionInformation : void* in/out
    wintypes.DWORD,  # PartitionInformationLength : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-memory-l1-1-8.dll')
QueryPartitionInformation = Fiddle::Function.new(
  lib['QueryPartitionInformation'],
  [
    Fiddle::TYPE_VOIDP,  # Partition : HANDLE
    Fiddle::TYPE_INT,  # PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS
    Fiddle::TYPE_VOIDP,  # PartitionInformation : void* in/out
    -Fiddle::TYPE_INT,  # PartitionInformationLength : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-memory-l1-1-8")]
extern "system" {
    fn QueryPartitionInformation(
        Partition: *mut core::ffi::c_void,  // HANDLE
        PartitionInformationClass: i32,  // WIN32_MEMORY_PARTITION_INFORMATION_CLASS
        PartitionInformation: *mut (),  // void* in/out
        PartitionInformationLength: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-memory-l1-1-8.dll")]
public static extern bool QueryPartitionInformation(IntPtr Partition, int PartitionInformationClass, IntPtr PartitionInformation, uint PartitionInformationLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-memory-l1-1-8_QueryPartitionInformation' -Namespace Win32 -PassThru
# $api::QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
#uselib "api-ms-win-core-memory-l1-1-8.dll"
#func global QueryPartitionInformation "QueryPartitionInformation" sptr, sptr, sptr, sptr
; QueryPartitionInformation Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength   ; 戻り値は stat
; Partition : HANDLE -> "sptr"
; PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> "sptr"
; PartitionInformation : void* in/out -> "sptr"
; PartitionInformationLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "api-ms-win-core-memory-l1-1-8.dll"
#cfunc global QueryPartitionInformation "QueryPartitionInformation" sptr, int, sptr, int
; res = QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
; Partition : HANDLE -> "sptr"
; PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> "int"
; PartitionInformation : void* in/out -> "sptr"
; PartitionInformationLength : DWORD -> "int"
; BOOL QueryPartitionInformation(HANDLE Partition, WIN32_MEMORY_PARTITION_INFORMATION_CLASS PartitionInformationClass, void* PartitionInformation, DWORD PartitionInformationLength)
#uselib "api-ms-win-core-memory-l1-1-8.dll"
#cfunc global QueryPartitionInformation "QueryPartitionInformation" intptr, int, intptr, int
; res = QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
; Partition : HANDLE -> "intptr"
; PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> "int"
; PartitionInformation : void* in/out -> "intptr"
; PartitionInformationLength : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_core_memory_l1_1_8 = windows.NewLazySystemDLL("api-ms-win-core-memory-l1-1-8.dll")
	procQueryPartitionInformation = api_ms_win_core_memory_l1_1_8.NewProc("QueryPartitionInformation")
)

// Partition (HANDLE), PartitionInformationClass (WIN32_MEMORY_PARTITION_INFORMATION_CLASS), PartitionInformation (void* in/out), PartitionInformationLength (DWORD)
r1, _, err := procQueryPartitionInformation.Call(
	uintptr(Partition),
	uintptr(PartitionInformationClass),
	uintptr(PartitionInformation),
	uintptr(PartitionInformationLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function QueryPartitionInformation(
  Partition: THandle;   // HANDLE
  PartitionInformationClass: Integer;   // WIN32_MEMORY_PARTITION_INFORMATION_CLASS
  PartitionInformation: Pointer;   // void* in/out
  PartitionInformationLength: DWORD   // DWORD
): BOOL; stdcall;
  external 'api-ms-win-core-memory-l1-1-8.dll' name 'QueryPartitionInformation';
result := DllCall("api-ms-win-core-memory-l1-1-8\QueryPartitionInformation"
    , "Ptr", Partition   ; HANDLE
    , "Int", PartitionInformationClass   ; WIN32_MEMORY_PARTITION_INFORMATION_CLASS
    , "Ptr", PartitionInformation   ; void* in/out
    , "UInt", PartitionInformationLength   ; DWORD
    , "Int")   ; return: BOOL
●QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength) = DLL("api-ms-win-core-memory-l1-1-8.dll", "bool QueryPartitionInformation(void*, int, void*, dword)")
# 呼び出し: QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
# Partition : HANDLE -> "void*"
# PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> "int"
# PartitionInformation : void* in/out -> "void*"
# PartitionInformationLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。