ホーム › Graphics.Gdi › AddFontResourceExA
AddFontResourceExA
関数指定したフォントリソースをシステムに追加する。
シグネチャ
// GDI32.dll (ANSI / -A)
#include <windows.h>
INT AddFontResourceExA(
LPCSTR name,
FONT_RESOURCE_CHARACTERISTICS fl,
void* res // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| name | LPCSTR | in |
| fl | FONT_RESOURCE_CHARACTERISTICS | in |
| res | void* | optional |
戻り値の型: INT
各言語での呼び出し定義
// GDI32.dll (ANSI / -A)
#include <windows.h>
INT AddFontResourceExA(
LPCSTR name,
FONT_RESOURCE_CHARACTERISTICS fl,
void* res // optional
);[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int AddFontResourceExA(
[MarshalAs(UnmanagedType.LPStr)] string name, // LPCSTR
uint fl, // FONT_RESOURCE_CHARACTERISTICS
IntPtr res // void* optional
);<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function AddFontResourceExA(
<MarshalAs(UnmanagedType.LPStr)> name As String, ' LPCSTR
fl As UInteger, ' FONT_RESOURCE_CHARACTERISTICS
res As IntPtr ' void* optional
) As Integer
End Function' name : LPCSTR
' fl : FONT_RESOURCE_CHARACTERISTICS
' res : void* optional
Declare PtrSafe Function AddFontResourceExA Lib "gdi32" ( _
ByVal name As String, _
ByVal fl As Long, _
ByVal res As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
AddFontResourceExA = ctypes.windll.gdi32.AddFontResourceExA
AddFontResourceExA.restype = ctypes.c_int
AddFontResourceExA.argtypes = [
wintypes.LPCSTR, # name : LPCSTR
wintypes.DWORD, # fl : FONT_RESOURCE_CHARACTERISTICS
ctypes.POINTER(None), # res : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
AddFontResourceExA = Fiddle::Function.new(
lib['AddFontResourceExA'],
[
Fiddle::TYPE_VOIDP, # name : LPCSTR
-Fiddle::TYPE_INT, # fl : FONT_RESOURCE_CHARACTERISTICS
Fiddle::TYPE_VOIDP, # res : void* optional
],
Fiddle::TYPE_INT)#[link(name = "gdi32")]
extern "system" {
fn AddFontResourceExA(
name: *const u8, // LPCSTR
fl: u32, // FONT_RESOURCE_CHARACTERISTICS
res: *mut () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Ansi)]
public static extern int AddFontResourceExA([MarshalAs(UnmanagedType.LPStr)] string name, uint fl, IntPtr res);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_AddFontResourceExA' -Namespace Win32 -PassThru
# $api::AddFontResourceExA(name, fl, res)#uselib "GDI32.dll"
#func global AddFontResourceExA "AddFontResourceExA" sptr, sptr, sptr
; AddFontResourceExA name, fl, res ; 戻り値は stat
; name : LPCSTR -> "sptr"
; fl : FONT_RESOURCE_CHARACTERISTICS -> "sptr"
; res : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "GDI32.dll"
#cfunc global AddFontResourceExA "AddFontResourceExA" str, int, sptr
; res = AddFontResourceExA(name, fl, res)
; name : LPCSTR -> "str"
; fl : FONT_RESOURCE_CHARACTERISTICS -> "int"
; res : void* optional -> "sptr"; INT AddFontResourceExA(LPCSTR name, FONT_RESOURCE_CHARACTERISTICS fl, void* res)
#uselib "GDI32.dll"
#cfunc global AddFontResourceExA "AddFontResourceExA" str, int, intptr
; res = AddFontResourceExA(name, fl, res)
; name : LPCSTR -> "str"
; fl : FONT_RESOURCE_CHARACTERISTICS -> "int"
; res : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procAddFontResourceExA = gdi32.NewProc("AddFontResourceExA")
)
// name (LPCSTR), fl (FONT_RESOURCE_CHARACTERISTICS), res (void* optional)
r1, _, err := procAddFontResourceExA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(name))),
uintptr(fl),
uintptr(res),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction AddFontResourceExA(
name: PAnsiChar; // LPCSTR
fl: DWORD; // FONT_RESOURCE_CHARACTERISTICS
res: Pointer // void* optional
): Integer; stdcall;
external 'GDI32.dll' name 'AddFontResourceExA';result := DllCall("GDI32\AddFontResourceExA"
, "AStr", name ; LPCSTR
, "UInt", fl ; FONT_RESOURCE_CHARACTERISTICS
, "Ptr", res ; void* optional
, "Int") ; return: INT●AddFontResourceExA(name, fl, res) = DLL("GDI32.dll", "int AddFontResourceExA(char*, dword, void*)")
# 呼び出し: AddFontResourceExA(name, fl, res)
# name : LPCSTR -> "char*"
# fl : FONT_RESOURCE_CHARACTERISTICS -> "dword"
# res : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。