ホーム › System.Memory › HeapReAlloc
HeapReAlloc
関数ヒープ上のメモリブロックを再割り当てする。
シグネチャ
// KERNEL32.dll
#include <windows.h>
void* HeapReAlloc(
HANDLE hHeap,
HEAP_FLAGS dwFlags,
void* lpMem, // optional
UINT_PTR dwBytes
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hHeap | HANDLE | inout |
| dwFlags | HEAP_FLAGS | in |
| lpMem | void* | inoptional |
| dwBytes | UINT_PTR | in |
戻り値の型: void*
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
void* HeapReAlloc(
HANDLE hHeap,
HEAP_FLAGS dwFlags,
void* lpMem, // optional
UINT_PTR dwBytes
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern IntPtr HeapReAlloc(
IntPtr hHeap, // HANDLE in/out
uint dwFlags, // HEAP_FLAGS
IntPtr lpMem, // void* optional
UIntPtr dwBytes // UINT_PTR
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function HeapReAlloc(
hHeap As IntPtr, ' HANDLE in/out
dwFlags As UInteger, ' HEAP_FLAGS
lpMem As IntPtr, ' void* optional
dwBytes As UIntPtr ' UINT_PTR
) As IntPtr
End Function' hHeap : HANDLE in/out
' dwFlags : HEAP_FLAGS
' lpMem : void* optional
' dwBytes : UINT_PTR
Declare PtrSafe Function HeapReAlloc Lib "kernel32" ( _
ByVal hHeap As LongPtr, _
ByVal dwFlags As Long, _
ByVal lpMem As LongPtr, _
ByVal dwBytes As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HeapReAlloc = ctypes.windll.kernel32.HeapReAlloc
HeapReAlloc.restype = ctypes.c_void_p
HeapReAlloc.argtypes = [
wintypes.HANDLE, # hHeap : HANDLE in/out
wintypes.DWORD, # dwFlags : HEAP_FLAGS
ctypes.POINTER(None), # lpMem : void* optional
ctypes.c_size_t, # dwBytes : UINT_PTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
HeapReAlloc = Fiddle::Function.new(
lib['HeapReAlloc'],
[
Fiddle::TYPE_VOIDP, # hHeap : HANDLE in/out
-Fiddle::TYPE_INT, # dwFlags : HEAP_FLAGS
Fiddle::TYPE_VOIDP, # lpMem : void* optional
Fiddle::TYPE_UINTPTR_T, # dwBytes : UINT_PTR
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn HeapReAlloc(
hHeap: *mut core::ffi::c_void, // HANDLE in/out
dwFlags: u32, // HEAP_FLAGS
lpMem: *mut (), // void* optional
dwBytes: usize // UINT_PTR
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern IntPtr HeapReAlloc(IntPtr hHeap, uint dwFlags, IntPtr lpMem, UIntPtr dwBytes);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_HeapReAlloc' -Namespace Win32 -PassThru
# $api::HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes)#uselib "KERNEL32.dll"
#func global HeapReAlloc "HeapReAlloc" sptr, sptr, sptr, sptr
; HeapReAlloc hHeap, dwFlags, lpMem, dwBytes ; 戻り値は stat
; hHeap : HANDLE in/out -> "sptr"
; dwFlags : HEAP_FLAGS -> "sptr"
; lpMem : void* optional -> "sptr"
; dwBytes : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global HeapReAlloc "HeapReAlloc" sptr, int, sptr, sptr
; res = HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes)
; hHeap : HANDLE in/out -> "sptr"
; dwFlags : HEAP_FLAGS -> "int"
; lpMem : void* optional -> "sptr"
; dwBytes : UINT_PTR -> "sptr"; void* HeapReAlloc(HANDLE hHeap, HEAP_FLAGS dwFlags, void* lpMem, UINT_PTR dwBytes)
#uselib "KERNEL32.dll"
#cfunc global HeapReAlloc "HeapReAlloc" intptr, int, intptr, intptr
; res = HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes)
; hHeap : HANDLE in/out -> "intptr"
; dwFlags : HEAP_FLAGS -> "int"
; lpMem : void* optional -> "intptr"
; dwBytes : UINT_PTR -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procHeapReAlloc = kernel32.NewProc("HeapReAlloc")
)
// hHeap (HANDLE in/out), dwFlags (HEAP_FLAGS), lpMem (void* optional), dwBytes (UINT_PTR)
r1, _, err := procHeapReAlloc.Call(
uintptr(hHeap),
uintptr(dwFlags),
uintptr(lpMem),
uintptr(dwBytes),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function HeapReAlloc(
hHeap: THandle; // HANDLE in/out
dwFlags: DWORD; // HEAP_FLAGS
lpMem: Pointer; // void* optional
dwBytes: NativeUInt // UINT_PTR
): Pointer; stdcall;
external 'KERNEL32.dll' name 'HeapReAlloc';result := DllCall("KERNEL32\HeapReAlloc"
, "Ptr", hHeap ; HANDLE in/out
, "UInt", dwFlags ; HEAP_FLAGS
, "Ptr", lpMem ; void* optional
, "UPtr", dwBytes ; UINT_PTR
, "Ptr") ; return: void*●HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes) = DLL("KERNEL32.dll", "void* HeapReAlloc(void*, dword, void*, int)")
# 呼び出し: HeapReAlloc(hHeap, dwFlags, lpMem, dwBytes)
# hHeap : HANDLE in/out -> "void*"
# dwFlags : HEAP_FLAGS -> "dword"
# lpMem : void* optional -> "void*"
# dwBytes : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。