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

AddFontMemResourceEx

関数
メモリ上のフォントデータをシステムに追加する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HANDLE AddFontMemResourceEx(
    void* pFileView,
    DWORD cjSize,
    void* pvResrved,   // optional
    DWORD* pNumFonts
);

パラメーター

名前方向
pFileViewvoid*in
cjSizeDWORDin
pvResrvedvoid*optional
pNumFontsDWORD*in

戻り値の型: HANDLE

各言語での呼び出し定義

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

HANDLE AddFontMemResourceEx(
    void* pFileView,
    DWORD cjSize,
    void* pvResrved,   // optional
    DWORD* pNumFonts
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr AddFontMemResourceEx(
    IntPtr pFileView,   // void*
    uint cjSize,   // DWORD
    IntPtr pvResrved,   // void* optional
    ref uint pNumFonts   // DWORD*
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function AddFontMemResourceEx(
    pFileView As IntPtr,   ' void*
    cjSize As UInteger,   ' DWORD
    pvResrved As IntPtr,   ' void* optional
    ByRef pNumFonts As UInteger   ' DWORD*
) As IntPtr
End Function
' pFileView : void*
' cjSize : DWORD
' pvResrved : void* optional
' pNumFonts : DWORD*
Declare PtrSafe Function AddFontMemResourceEx Lib "gdi32" ( _
    ByVal pFileView As LongPtr, _
    ByVal cjSize As Long, _
    ByVal pvResrved As LongPtr, _
    ByRef pNumFonts As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AddFontMemResourceEx = ctypes.windll.gdi32.AddFontMemResourceEx
AddFontMemResourceEx.restype = ctypes.c_void_p
AddFontMemResourceEx.argtypes = [
    ctypes.POINTER(None),  # pFileView : void*
    wintypes.DWORD,  # cjSize : DWORD
    ctypes.POINTER(None),  # pvResrved : void* optional
    ctypes.POINTER(wintypes.DWORD),  # pNumFonts : DWORD*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
AddFontMemResourceEx = Fiddle::Function.new(
  lib['AddFontMemResourceEx'],
  [
    Fiddle::TYPE_VOIDP,  # pFileView : void*
    -Fiddle::TYPE_INT,  # cjSize : DWORD
    Fiddle::TYPE_VOIDP,  # pvResrved : void* optional
    Fiddle::TYPE_VOIDP,  # pNumFonts : DWORD*
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "gdi32")]
extern "system" {
    fn AddFontMemResourceEx(
        pFileView: *mut (),  // void*
        cjSize: u32,  // DWORD
        pvResrved: *mut (),  // void* optional
        pNumFonts: *mut u32  // DWORD*
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern IntPtr AddFontMemResourceEx(IntPtr pFileView, uint cjSize, IntPtr pvResrved, ref uint pNumFonts);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_AddFontMemResourceEx' -Namespace Win32 -PassThru
# $api::AddFontMemResourceEx(pFileView, cjSize, pvResrved, pNumFonts)
#uselib "GDI32.dll"
#func global AddFontMemResourceEx "AddFontMemResourceEx" sptr, sptr, sptr, sptr
; AddFontMemResourceEx pFileView, cjSize, pvResrved, varptr(pNumFonts)   ; 戻り値は stat
; pFileView : void* -> "sptr"
; cjSize : DWORD -> "sptr"
; pvResrved : void* optional -> "sptr"
; pNumFonts : DWORD* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global AddFontMemResourceEx "AddFontMemResourceEx" sptr, int, sptr, var
; res = AddFontMemResourceEx(pFileView, cjSize, pvResrved, pNumFonts)
; pFileView : void* -> "sptr"
; cjSize : DWORD -> "int"
; pvResrved : void* optional -> "sptr"
; pNumFonts : DWORD* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HANDLE AddFontMemResourceEx(void* pFileView, DWORD cjSize, void* pvResrved, DWORD* pNumFonts)
#uselib "GDI32.dll"
#cfunc global AddFontMemResourceEx "AddFontMemResourceEx" intptr, int, intptr, var
; res = AddFontMemResourceEx(pFileView, cjSize, pvResrved, pNumFonts)
; pFileView : void* -> "intptr"
; cjSize : DWORD -> "int"
; pvResrved : void* optional -> "intptr"
; pNumFonts : DWORD* -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procAddFontMemResourceEx = gdi32.NewProc("AddFontMemResourceEx")
)

// pFileView (void*), cjSize (DWORD), pvResrved (void* optional), pNumFonts (DWORD*)
r1, _, err := procAddFontMemResourceEx.Call(
	uintptr(pFileView),
	uintptr(cjSize),
	uintptr(pvResrved),
	uintptr(pNumFonts),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HANDLE
function AddFontMemResourceEx(
  pFileView: Pointer;   // void*
  cjSize: DWORD;   // DWORD
  pvResrved: Pointer;   // void* optional
  pNumFonts: Pointer   // DWORD*
): THandle; stdcall;
  external 'GDI32.dll' name 'AddFontMemResourceEx';
result := DllCall("GDI32\AddFontMemResourceEx"
    , "Ptr", pFileView   ; void*
    , "UInt", cjSize   ; DWORD
    , "Ptr", pvResrved   ; void* optional
    , "Ptr", pNumFonts   ; DWORD*
    , "Ptr")   ; return: HANDLE
●AddFontMemResourceEx(pFileView, cjSize, pvResrved, pNumFonts) = DLL("GDI32.dll", "void* AddFontMemResourceEx(void*, dword, void*, void*)")
# 呼び出し: AddFontMemResourceEx(pFileView, cjSize, pvResrved, pNumFonts)
# pFileView : void* -> "void*"
# cjSize : DWORD -> "dword"
# pvResrved : void* optional -> "void*"
# pNumFonts : DWORD* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。