ホーム › Networking.WindowsWebServices › WsCreateHeap
WsCreateHeap
関数メモリ管理用のヒープを作成する。
シグネチャ
// webservices.dll
#include <windows.h>
HRESULT WsCreateHeap(
UINT_PTR maxSize,
UINT_PTR trimSize,
const WS_HEAP_PROPERTY* properties, // optional
DWORD propertyCount,
WS_HEAP** heap,
WS_ERROR* error // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| maxSize | UINT_PTR | in |
| trimSize | UINT_PTR | in |
| properties | WS_HEAP_PROPERTY* | inoptional |
| propertyCount | DWORD | in |
| heap | WS_HEAP** | out |
| error | WS_ERROR* | inoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// webservices.dll
#include <windows.h>
HRESULT WsCreateHeap(
UINT_PTR maxSize,
UINT_PTR trimSize,
const WS_HEAP_PROPERTY* properties, // optional
DWORD propertyCount,
WS_HEAP** heap,
WS_ERROR* error // optional
);[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsCreateHeap(
UIntPtr maxSize, // UINT_PTR
UIntPtr trimSize, // UINT_PTR
IntPtr properties, // WS_HEAP_PROPERTY* optional
uint propertyCount, // DWORD
IntPtr heap, // WS_HEAP** out
IntPtr error // WS_ERROR* optional
);<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsCreateHeap(
maxSize As UIntPtr, ' UINT_PTR
trimSize As UIntPtr, ' UINT_PTR
properties As IntPtr, ' WS_HEAP_PROPERTY* optional
propertyCount As UInteger, ' DWORD
heap As IntPtr, ' WS_HEAP** out
[error] As IntPtr ' WS_ERROR* optional
) As Integer
End Function' maxSize : UINT_PTR
' trimSize : UINT_PTR
' properties : WS_HEAP_PROPERTY* optional
' propertyCount : DWORD
' heap : WS_HEAP** out
' error : WS_ERROR* optional
Declare PtrSafe Function WsCreateHeap Lib "webservices" ( _
ByVal maxSize As LongPtr, _
ByVal trimSize As LongPtr, _
ByVal properties As LongPtr, _
ByVal propertyCount As Long, _
ByVal heap As LongPtr, _
ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WsCreateHeap = ctypes.windll.webservices.WsCreateHeap
WsCreateHeap.restype = ctypes.c_int
WsCreateHeap.argtypes = [
ctypes.c_size_t, # maxSize : UINT_PTR
ctypes.c_size_t, # trimSize : UINT_PTR
ctypes.c_void_p, # properties : WS_HEAP_PROPERTY* optional
wintypes.DWORD, # propertyCount : DWORD
ctypes.c_void_p, # heap : WS_HEAP** out
ctypes.c_void_p, # error : WS_ERROR* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('webservices.dll')
WsCreateHeap = Fiddle::Function.new(
lib['WsCreateHeap'],
[
Fiddle::TYPE_UINTPTR_T, # maxSize : UINT_PTR
Fiddle::TYPE_UINTPTR_T, # trimSize : UINT_PTR
Fiddle::TYPE_VOIDP, # properties : WS_HEAP_PROPERTY* optional
-Fiddle::TYPE_INT, # propertyCount : DWORD
Fiddle::TYPE_VOIDP, # heap : WS_HEAP** out
Fiddle::TYPE_VOIDP, # error : WS_ERROR* optional
],
Fiddle::TYPE_INT)#[link(name = "webservices")]
extern "system" {
fn WsCreateHeap(
maxSize: usize, // UINT_PTR
trimSize: usize, // UINT_PTR
properties: *const WS_HEAP_PROPERTY, // WS_HEAP_PROPERTY* optional
propertyCount: u32, // DWORD
heap: *mut *mut isize, // WS_HEAP** out
error: *mut isize // WS_ERROR* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("webservices.dll")]
public static extern int WsCreateHeap(UIntPtr maxSize, UIntPtr trimSize, IntPtr properties, uint propertyCount, IntPtr heap, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsCreateHeap' -Namespace Win32 -PassThru
# $api::WsCreateHeap(maxSize, trimSize, properties, propertyCount, heap, error)#uselib "webservices.dll"
#func global WsCreateHeap "WsCreateHeap" sptr, sptr, sptr, sptr, sptr, sptr
; WsCreateHeap maxSize, trimSize, varptr(properties), propertyCount, heap, error ; 戻り値は stat
; maxSize : UINT_PTR -> "sptr"
; trimSize : UINT_PTR -> "sptr"
; properties : WS_HEAP_PROPERTY* optional -> "sptr"
; propertyCount : DWORD -> "sptr"
; heap : WS_HEAP** out -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "webservices.dll" #cfunc global WsCreateHeap "WsCreateHeap" sptr, sptr, var, int, int, int ; res = WsCreateHeap(maxSize, trimSize, properties, propertyCount, heap, error) ; maxSize : UINT_PTR -> "sptr" ; trimSize : UINT_PTR -> "sptr" ; properties : WS_HEAP_PROPERTY* optional -> "var" ; propertyCount : DWORD -> "int" ; heap : WS_HEAP** out -> "int" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "webservices.dll" #cfunc global WsCreateHeap "WsCreateHeap" sptr, sptr, sptr, int, int, int ; res = WsCreateHeap(maxSize, trimSize, varptr(properties), propertyCount, heap, error) ; maxSize : UINT_PTR -> "sptr" ; trimSize : UINT_PTR -> "sptr" ; properties : WS_HEAP_PROPERTY* optional -> "sptr" ; propertyCount : DWORD -> "int" ; heap : WS_HEAP** out -> "int" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WsCreateHeap(UINT_PTR maxSize, UINT_PTR trimSize, WS_HEAP_PROPERTY* properties, DWORD propertyCount, WS_HEAP** heap, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsCreateHeap "WsCreateHeap" intptr, intptr, var, int, int, int ; res = WsCreateHeap(maxSize, trimSize, properties, propertyCount, heap, error) ; maxSize : UINT_PTR -> "intptr" ; trimSize : UINT_PTR -> "intptr" ; properties : WS_HEAP_PROPERTY* optional -> "var" ; propertyCount : DWORD -> "int" ; heap : WS_HEAP** out -> "int" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WsCreateHeap(UINT_PTR maxSize, UINT_PTR trimSize, WS_HEAP_PROPERTY* properties, DWORD propertyCount, WS_HEAP** heap, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsCreateHeap "WsCreateHeap" intptr, intptr, intptr, int, int, int ; res = WsCreateHeap(maxSize, trimSize, varptr(properties), propertyCount, heap, error) ; maxSize : UINT_PTR -> "intptr" ; trimSize : UINT_PTR -> "intptr" ; properties : WS_HEAP_PROPERTY* optional -> "intptr" ; propertyCount : DWORD -> "int" ; heap : WS_HEAP** out -> "int" ; error : WS_ERROR* optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
webservices = windows.NewLazySystemDLL("webservices.dll")
procWsCreateHeap = webservices.NewProc("WsCreateHeap")
)
// maxSize (UINT_PTR), trimSize (UINT_PTR), properties (WS_HEAP_PROPERTY* optional), propertyCount (DWORD), heap (WS_HEAP** out), error (WS_ERROR* optional)
r1, _, err := procWsCreateHeap.Call(
uintptr(maxSize),
uintptr(trimSize),
uintptr(properties),
uintptr(propertyCount),
uintptr(heap),
uintptr(error),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WsCreateHeap(
maxSize: NativeUInt; // UINT_PTR
trimSize: NativeUInt; // UINT_PTR
properties: Pointer; // WS_HEAP_PROPERTY* optional
propertyCount: DWORD; // DWORD
heap: Pointer; // WS_HEAP** out
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsCreateHeap';result := DllCall("webservices\WsCreateHeap"
, "UPtr", maxSize ; UINT_PTR
, "UPtr", trimSize ; UINT_PTR
, "Ptr", properties ; WS_HEAP_PROPERTY* optional
, "UInt", propertyCount ; DWORD
, "Ptr", heap ; WS_HEAP** out
, "Ptr", error ; WS_ERROR* optional
, "Int") ; return: HRESULT●WsCreateHeap(maxSize, trimSize, properties, propertyCount, heap, error) = DLL("webservices.dll", "int WsCreateHeap(int, int, void*, dword, void*, void*)")
# 呼び出し: WsCreateHeap(maxSize, trimSize, properties, propertyCount, heap, error)
# maxSize : UINT_PTR -> "int"
# trimSize : UINT_PTR -> "int"
# properties : WS_HEAP_PROPERTY* optional -> "void*"
# propertyCount : DWORD -> "dword"
# heap : WS_HEAP** out -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。