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

GdipPrivateAddMemoryFont

関数
メモリ上のフォントデータをプライベートコレクションに追加する。
DLLgdiplus.dll呼出規約winapi

シグネチャ

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

Status GdipPrivateAddMemoryFont(
    GpFontCollection* fontCollection,
    const void* memory,
    INT length
);

パラメーター

名前方向
fontCollectionGpFontCollection*inout
memoryvoid*in
lengthINTin

戻り値の型: Status

各言語での呼び出し定義

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

Status GdipPrivateAddMemoryFont(
    GpFontCollection* fontCollection,
    const void* memory,
    INT length
);
[DllImport("gdiplus.dll", ExactSpelling = true)]
static extern int GdipPrivateAddMemoryFont(
    IntPtr fontCollection,   // GpFontCollection* in/out
    IntPtr memory,   // void*
    int length   // INT
);
<DllImport("gdiplus.dll", ExactSpelling:=True)>
Public Shared Function GdipPrivateAddMemoryFont(
    fontCollection As IntPtr,   ' GpFontCollection* in/out
    memory As IntPtr,   ' void*
    length As Integer   ' INT
) As Integer
End Function
' fontCollection : GpFontCollection* in/out
' memory : void*
' length : INT
Declare PtrSafe Function GdipPrivateAddMemoryFont Lib "gdiplus" ( _
    ByVal fontCollection As LongPtr, _
    ByVal memory As LongPtr, _
    ByVal length As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipPrivateAddMemoryFont = ctypes.windll.gdiplus.GdipPrivateAddMemoryFont
GdipPrivateAddMemoryFont.restype = ctypes.c_int
GdipPrivateAddMemoryFont.argtypes = [
    ctypes.c_void_p,  # fontCollection : GpFontCollection* in/out
    ctypes.POINTER(None),  # memory : void*
    ctypes.c_int,  # length : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipPrivateAddMemoryFont = Fiddle::Function.new(
  lib['GdipPrivateAddMemoryFont'],
  [
    Fiddle::TYPE_VOIDP,  # fontCollection : GpFontCollection* in/out
    Fiddle::TYPE_VOIDP,  # memory : void*
    Fiddle::TYPE_INT,  # length : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipPrivateAddMemoryFont(
        fontCollection: *mut GpFontCollection,  // GpFontCollection* in/out
        memory: *const (),  // void*
        length: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll")]
public static extern int GdipPrivateAddMemoryFont(IntPtr fontCollection, IntPtr memory, int length);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipPrivateAddMemoryFont' -Namespace Win32 -PassThru
# $api::GdipPrivateAddMemoryFont(fontCollection, memory, length)
#uselib "gdiplus.dll"
#func global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" sptr, sptr, sptr
; GdipPrivateAddMemoryFont varptr(fontCollection), memory, length   ; 戻り値は stat
; fontCollection : GpFontCollection* in/out -> "sptr"
; memory : void* -> "sptr"
; length : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" var, sptr, int
; res = GdipPrivateAddMemoryFont(fontCollection, memory, length)
; fontCollection : GpFontCollection* in/out -> "var"
; memory : void* -> "sptr"
; length : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipPrivateAddMemoryFont(GpFontCollection* fontCollection, void* memory, INT length)
#uselib "gdiplus.dll"
#cfunc global GdipPrivateAddMemoryFont "GdipPrivateAddMemoryFont" var, intptr, int
; res = GdipPrivateAddMemoryFont(fontCollection, memory, length)
; fontCollection : GpFontCollection* in/out -> "var"
; memory : void* -> "intptr"
; length : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipPrivateAddMemoryFont = gdiplus.NewProc("GdipPrivateAddMemoryFont")
)

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