Win32 API 日本語リファレンス
ホームGraphics.GdiPlus › GdipAlloc

GdipAlloc

関数
GDI+用のメモリブロックを確保する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

// gdiplus.dll
#include <windows.h>

void* GdipAlloc(
    UINT_PTR size
);

パラメーター

名前方向
sizeUINT_PTRin

戻り値の型: void*

各言語での呼び出し定義

// gdiplus.dll
#include <windows.h>

void* GdipAlloc(
    UINT_PTR size
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern IntPtr GdipAlloc(
    UIntPtr size   // UINT_PTR
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipAlloc(
    size As UIntPtr   ' UINT_PTR
) As IntPtr
End Function
' size : UINT_PTR
Declare PtrSafe Function GdipAlloc Lib "gdiplus" ( _
    ByVal size As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipAlloc = ctypes.windll.gdiplus.GdipAlloc
GdipAlloc.restype = ctypes.c_void_p
GdipAlloc.argtypes = [
    ctypes.c_size_t,  # size : UINT_PTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipAlloc = Fiddle::Function.new(
  lib['GdipAlloc'],
  [
    Fiddle::TYPE_UINTPTR_T,  # size : UINT_PTR
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipAlloc(
        size: usize  // UINT_PTR
    ) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern IntPtr GdipAlloc(UIntPtr size);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipAlloc' -Namespace Win32 -PassThru
# $api::GdipAlloc(size)
#uselib "gdiplus.dll"
#func global GdipAlloc "GdipAlloc" sptr
; GdipAlloc size   ; 戻り値は stat
; size : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "gdiplus.dll"
#cfunc global GdipAlloc "GdipAlloc" sptr
; res = GdipAlloc(size)
; size : UINT_PTR -> "sptr"
; void* GdipAlloc(UINT_PTR size)
#uselib "gdiplus.dll"
#cfunc global GdipAlloc "GdipAlloc" intptr
; res = GdipAlloc(size)
; size : UINT_PTR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipAlloc = gdiplus.NewProc("GdipAlloc")
)

// size (UINT_PTR)
r1, _, err := procGdipAlloc.Call(
	uintptr(size),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void*
function GdipAlloc(
  size: NativeUInt   // UINT_PTR
): Pointer; stdcall;
  external 'gdiplus.dll' name 'GdipAlloc';
result := DllCall("gdiplus\GdipAlloc"
    , "UPtr", size   ; UINT_PTR
    , "Ptr")   ; return: void*
●GdipAlloc(size) = DLL("gdiplus.dll", "void* GdipAlloc(int)")
# 呼び出し: GdipAlloc(size)
# size : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。