ホーム › System.Memory › QueryPartitionInformation
QueryPartitionInformation
関数メモリパーティションの情報をクラス別に問い合わせる。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Partition | HANDLE | in | 情報を問い合わせるメモリパーティションのハンドル。 |
| PartitionInformationClass | WIN32_MEMORY_PARTITION_INFORMATION_CLASS | in | 取得する情報の種類を示す列挙値。 |
| PartitionInformation | void* | inout | 取得した情報を受け取るバッファへのポインタ。 |
| PartitionInformationLength | DWORD | in | PartitionInformationバッファのバイト数。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "api-ms-win-core-memory-l1-1-8" fn QueryPartitionInformation(
Partition: ?*anyopaque, // HANDLE
PartitionInformationClass: i32, // WIN32_MEMORY_PARTITION_INFORMATION_CLASS
PartitionInformation: ?*anyopaque, // void* in/out
PartitionInformationLength: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc QueryPartitionInformation(
Partition: pointer, # HANDLE
PartitionInformationClass: int32, # WIN32_MEMORY_PARTITION_INFORMATION_CLASS
PartitionInformation: pointer, # void* in/out
PartitionInformationLength: uint32 # DWORD
): int32 {.importc: "QueryPartitionInformation", stdcall, dynlib: "api-ms-win-core-memory-l1-1-8.dll".}pragma(lib, "api-ms-win-core-memory-l1-1-8");
extern(Windows)
int QueryPartitionInformation(
void* Partition, // HANDLE
int PartitionInformationClass, // WIN32_MEMORY_PARTITION_INFORMATION_CLASS
void* PartitionInformation, // void* in/out
uint PartitionInformationLength // DWORD
);ccall((:QueryPartitionInformation, "api-ms-win-core-memory-l1-1-8.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Ptr{Cvoid}, UInt32),
Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
# Partition : HANDLE -> Ptr{Cvoid}
# PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> Int32
# PartitionInformation : void* in/out -> Ptr{Cvoid}
# PartitionInformationLength : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t QueryPartitionInformation(
void* Partition,
int32_t PartitionInformationClass,
void* PartitionInformation,
uint32_t PartitionInformationLength);
]]
local api-ms-win-core-memory-l1-1-8 = ffi.load("api-ms-win-core-memory-l1-1-8")
-- api-ms-win-core-memory-l1-1-8.QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
-- Partition : HANDLE
-- PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS
-- PartitionInformation : void* in/out
-- PartitionInformationLength : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-memory-l1-1-8.dll');
const QueryPartitionInformation = lib.func('__stdcall', 'QueryPartitionInformation', 'int32_t', ['void *', 'int32_t', 'void *', 'uint32_t']);
// QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
// Partition : HANDLE -> 'void *'
// PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> 'int32_t'
// PartitionInformation : void* in/out -> 'void *'
// PartitionInformationLength : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-core-memory-l1-1-8.dll", {
QueryPartitionInformation: { parameters: ["pointer", "i32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength)
// Partition : HANDLE -> "pointer"
// PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> "i32"
// PartitionInformation : void* in/out -> "pointer"
// PartitionInformationLength : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t QueryPartitionInformation(
void* Partition,
int32_t PartitionInformationClass,
void* PartitionInformation,
uint32_t PartitionInformationLength);
C, "api-ms-win-core-memory-l1-1-8.dll");
// $ffi->QueryPartitionInformation(Partition, PartitionInformationClass, PartitionInformation, PartitionInformationLength);
// Partition : HANDLE
// PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS
// PartitionInformation : void* in/out
// PartitionInformationLength : 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 Api-ms-win-core-memory-l1-1-8 extends StdCallLibrary {
Api-ms-win-core-memory-l1-1-8 INSTANCE = Native.load("api-ms-win-core-memory-l1-1-8", Api-ms-win-core-memory-l1-1-8.class);
boolean QueryPartitionInformation(
Pointer Partition, // HANDLE
int PartitionInformationClass, // WIN32_MEMORY_PARTITION_INFORMATION_CLASS
Pointer PartitionInformation, // void* in/out
int PartitionInformationLength // DWORD
);
}@[Link("api-ms-win-core-memory-l1-1-8")]
lib Libapi-ms-win-core-memory-l1-1-8
fun QueryPartitionInformation = QueryPartitionInformation(
Partition : Void*, # HANDLE
PartitionInformationClass : Int32, # WIN32_MEMORY_PARTITION_INFORMATION_CLASS
PartitionInformation : Void*, # void* in/out
PartitionInformationLength : 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 QueryPartitionInformationNative = Int32 Function(Pointer<Void>, Int32, Pointer<Void>, Uint32);
typedef QueryPartitionInformationDart = int Function(Pointer<Void>, int, Pointer<Void>, int);
final QueryPartitionInformation = DynamicLibrary.open('api-ms-win-core-memory-l1-1-8.dll')
.lookupFunction<QueryPartitionInformationNative, QueryPartitionInformationDart>('QueryPartitionInformation');
// Partition : HANDLE -> Pointer<Void>
// PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> Int32
// PartitionInformation : void* in/out -> Pointer<Void>
// PartitionInformationLength : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "QueryPartitionInformation"
c_QueryPartitionInformation :: Ptr () -> Int32 -> Ptr () -> Word32 -> IO CInt
-- Partition : HANDLE -> Ptr ()
-- PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> Int32
-- PartitionInformation : void* in/out -> Ptr ()
-- PartitionInformationLength : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let querypartitioninformation =
foreign "QueryPartitionInformation"
((ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* Partition : HANDLE -> (ptr void) *)
(* PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> int32_t *)
(* PartitionInformation : void* in/out -> (ptr void) *)
(* PartitionInformationLength : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-core-memory-l1-1-8 (t "api-ms-win-core-memory-l1-1-8.dll"))
(cffi:use-foreign-library api-ms-win-core-memory-l1-1-8)
(cffi:defcfun ("QueryPartitionInformation" query-partition-information :convention :stdcall) :int32
(partition :pointer) ; HANDLE
(partition-information-class :int32) ; WIN32_MEMORY_PARTITION_INFORMATION_CLASS
(partition-information :pointer) ; void* in/out
(partition-information-length :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $QueryPartitionInformation = Win32::API::More->new('api-ms-win-core-memory-l1-1-8',
'BOOL QueryPartitionInformation(HANDLE Partition, int PartitionInformationClass, LPVOID PartitionInformation, DWORD PartitionInformationLength)');
# my $ret = $QueryPartitionInformation->Call($Partition, $PartitionInformationClass, $PartitionInformation, $PartitionInformationLength);
# Partition : HANDLE -> HANDLE
# PartitionInformationClass : WIN32_MEMORY_PARTITION_INFORMATION_CLASS -> int
# PartitionInformation : void* in/out -> LPVOID
# PartitionInformationLength : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。