ホーム › System.Memory › HeapSetInformation
HeapSetInformation
関数ヒープの動作に関する情報を設定する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL HeapSetInformation(
HANDLE HeapHandle, // optional
HEAP_INFORMATION_CLASS HeapInformationClass,
void* HeapInformation, // optional
UINT_PTR HeapInformationLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| HeapHandle | HANDLE | inoptional |
| HeapInformationClass | HEAP_INFORMATION_CLASS | in |
| HeapInformation | void* | inoptional |
| HeapInformationLength | UINT_PTR | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL HeapSetInformation(
HANDLE HeapHandle, // optional
HEAP_INFORMATION_CLASS HeapInformationClass,
void* HeapInformation, // optional
UINT_PTR HeapInformationLength
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool HeapSetInformation(
IntPtr HeapHandle, // HANDLE optional
int HeapInformationClass, // HEAP_INFORMATION_CLASS
IntPtr HeapInformation, // void* optional
UIntPtr HeapInformationLength // UINT_PTR
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function HeapSetInformation(
HeapHandle As IntPtr, ' HANDLE optional
HeapInformationClass As Integer, ' HEAP_INFORMATION_CLASS
HeapInformation As IntPtr, ' void* optional
HeapInformationLength As UIntPtr ' UINT_PTR
) As Boolean
End Function' HeapHandle : HANDLE optional
' HeapInformationClass : HEAP_INFORMATION_CLASS
' HeapInformation : void* optional
' HeapInformationLength : UINT_PTR
Declare PtrSafe Function HeapSetInformation Lib "kernel32" ( _
ByVal HeapHandle As LongPtr, _
ByVal HeapInformationClass As Long, _
ByVal HeapInformation As LongPtr, _
ByVal HeapInformationLength As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HeapSetInformation = ctypes.windll.kernel32.HeapSetInformation
HeapSetInformation.restype = wintypes.BOOL
HeapSetInformation.argtypes = [
wintypes.HANDLE, # HeapHandle : HANDLE optional
ctypes.c_int, # HeapInformationClass : HEAP_INFORMATION_CLASS
ctypes.POINTER(None), # HeapInformation : void* optional
ctypes.c_size_t, # HeapInformationLength : UINT_PTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
HeapSetInformation = Fiddle::Function.new(
lib['HeapSetInformation'],
[
Fiddle::TYPE_VOIDP, # HeapHandle : HANDLE optional
Fiddle::TYPE_INT, # HeapInformationClass : HEAP_INFORMATION_CLASS
Fiddle::TYPE_VOIDP, # HeapInformation : void* optional
Fiddle::TYPE_UINTPTR_T, # HeapInformationLength : UINT_PTR
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn HeapSetInformation(
HeapHandle: *mut core::ffi::c_void, // HANDLE optional
HeapInformationClass: i32, // HEAP_INFORMATION_CLASS
HeapInformation: *mut (), // void* optional
HeapInformationLength: usize // UINT_PTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool HeapSetInformation(IntPtr HeapHandle, int HeapInformationClass, IntPtr HeapInformation, UIntPtr HeapInformationLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_HeapSetInformation' -Namespace Win32 -PassThru
# $api::HeapSetInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength)#uselib "KERNEL32.dll"
#func global HeapSetInformation "HeapSetInformation" sptr, sptr, sptr, sptr
; HeapSetInformation HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength ; 戻り値は stat
; HeapHandle : HANDLE optional -> "sptr"
; HeapInformationClass : HEAP_INFORMATION_CLASS -> "sptr"
; HeapInformation : void* optional -> "sptr"
; HeapInformationLength : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global HeapSetInformation "HeapSetInformation" sptr, int, sptr, sptr
; res = HeapSetInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength)
; HeapHandle : HANDLE optional -> "sptr"
; HeapInformationClass : HEAP_INFORMATION_CLASS -> "int"
; HeapInformation : void* optional -> "sptr"
; HeapInformationLength : UINT_PTR -> "sptr"; BOOL HeapSetInformation(HANDLE HeapHandle, HEAP_INFORMATION_CLASS HeapInformationClass, void* HeapInformation, UINT_PTR HeapInformationLength)
#uselib "KERNEL32.dll"
#cfunc global HeapSetInformation "HeapSetInformation" intptr, int, intptr, intptr
; res = HeapSetInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength)
; HeapHandle : HANDLE optional -> "intptr"
; HeapInformationClass : HEAP_INFORMATION_CLASS -> "int"
; HeapInformation : void* optional -> "intptr"
; HeapInformationLength : UINT_PTR -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procHeapSetInformation = kernel32.NewProc("HeapSetInformation")
)
// HeapHandle (HANDLE optional), HeapInformationClass (HEAP_INFORMATION_CLASS), HeapInformation (void* optional), HeapInformationLength (UINT_PTR)
r1, _, err := procHeapSetInformation.Call(
uintptr(HeapHandle),
uintptr(HeapInformationClass),
uintptr(HeapInformation),
uintptr(HeapInformationLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction HeapSetInformation(
HeapHandle: THandle; // HANDLE optional
HeapInformationClass: Integer; // HEAP_INFORMATION_CLASS
HeapInformation: Pointer; // void* optional
HeapInformationLength: NativeUInt // UINT_PTR
): BOOL; stdcall;
external 'KERNEL32.dll' name 'HeapSetInformation';result := DllCall("KERNEL32\HeapSetInformation"
, "Ptr", HeapHandle ; HANDLE optional
, "Int", HeapInformationClass ; HEAP_INFORMATION_CLASS
, "Ptr", HeapInformation ; void* optional
, "UPtr", HeapInformationLength ; UINT_PTR
, "Int") ; return: BOOL●HeapSetInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength) = DLL("KERNEL32.dll", "bool HeapSetInformation(void*, int, void*, int)")
# 呼び出し: HeapSetInformation(HeapHandle, HeapInformationClass, HeapInformation, HeapInformationLength)
# HeapHandle : HANDLE optional -> "void*"
# HeapInformationClass : HEAP_INFORMATION_CLASS -> "int"
# HeapInformation : void* optional -> "void*"
# HeapInformationLength : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。