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