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

CreateScalableFontResourceW

関数
スケーラブルフォント用のリソースファイルを作成する。
DLLGDI32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// GDI32.dll  (Unicode / -W)
#include <windows.h>

BOOL CreateScalableFontResourceW(
    DWORD fdwHidden,
    LPCWSTR lpszFont,
    LPCWSTR lpszFile,
    LPCWSTR lpszPath   // optional
);

パラメーター

名前方向
fdwHiddenDWORDin
lpszFontLPCWSTRin
lpszFileLPCWSTRin
lpszPathLPCWSTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

// GDI32.dll  (Unicode / -W)
#include <windows.h>

BOOL CreateScalableFontResourceW(
    DWORD fdwHidden,
    LPCWSTR lpszFont,
    LPCWSTR lpszFile,
    LPCWSTR lpszPath   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool CreateScalableFontResourceW(
    uint fdwHidden,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string lpszFont,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string lpszFile,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string lpszPath   // LPCWSTR optional
);
<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateScalableFontResourceW(
    fdwHidden As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> lpszFont As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszFile As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszPath As String   ' LPCWSTR optional
) As Boolean
End Function
' fdwHidden : DWORD
' lpszFont : LPCWSTR
' lpszFile : LPCWSTR
' lpszPath : LPCWSTR optional
Declare PtrSafe Function CreateScalableFontResourceW Lib "gdi32" ( _
    ByVal fdwHidden As Long, _
    ByVal lpszFont As LongPtr, _
    ByVal lpszFile As LongPtr, _
    ByVal lpszPath As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateScalableFontResourceW = ctypes.windll.gdi32.CreateScalableFontResourceW
CreateScalableFontResourceW.restype = wintypes.BOOL
CreateScalableFontResourceW.argtypes = [
    wintypes.DWORD,  # fdwHidden : DWORD
    wintypes.LPCWSTR,  # lpszFont : LPCWSTR
    wintypes.LPCWSTR,  # lpszFile : LPCWSTR
    wintypes.LPCWSTR,  # lpszPath : LPCWSTR optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
CreateScalableFontResourceW = Fiddle::Function.new(
  lib['CreateScalableFontResourceW'],
  [
    -Fiddle::TYPE_INT,  # fdwHidden : DWORD
    Fiddle::TYPE_VOIDP,  # lpszFont : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpszFile : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpszPath : LPCWSTR optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "gdi32")]
extern "system" {
    fn CreateScalableFontResourceW(
        fdwHidden: u32,  // DWORD
        lpszFont: *const u16,  // LPCWSTR
        lpszFile: *const u16,  // LPCWSTR
        lpszPath: *const u16  // LPCWSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CreateScalableFontResourceW(uint fdwHidden, [MarshalAs(UnmanagedType.LPWStr)] string lpszFont, [MarshalAs(UnmanagedType.LPWStr)] string lpszFile, [MarshalAs(UnmanagedType.LPWStr)] string lpszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_CreateScalableFontResourceW' -Namespace Win32 -PassThru
# $api::CreateScalableFontResourceW(fdwHidden, lpszFont, lpszFile, lpszPath)
#uselib "GDI32.dll"
#func global CreateScalableFontResourceW "CreateScalableFontResourceW" wptr, wptr, wptr, wptr
; CreateScalableFontResourceW fdwHidden, lpszFont, lpszFile, lpszPath   ; 戻り値は stat
; fdwHidden : DWORD -> "wptr"
; lpszFont : LPCWSTR -> "wptr"
; lpszFile : LPCWSTR -> "wptr"
; lpszPath : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global CreateScalableFontResourceW "CreateScalableFontResourceW" int, wstr, wstr, wstr
; res = CreateScalableFontResourceW(fdwHidden, lpszFont, lpszFile, lpszPath)
; fdwHidden : DWORD -> "int"
; lpszFont : LPCWSTR -> "wstr"
; lpszFile : LPCWSTR -> "wstr"
; lpszPath : LPCWSTR optional -> "wstr"
; BOOL CreateScalableFontResourceW(DWORD fdwHidden, LPCWSTR lpszFont, LPCWSTR lpszFile, LPCWSTR lpszPath)
#uselib "GDI32.dll"
#cfunc global CreateScalableFontResourceW "CreateScalableFontResourceW" int, wstr, wstr, wstr
; res = CreateScalableFontResourceW(fdwHidden, lpszFont, lpszFile, lpszPath)
; fdwHidden : DWORD -> "int"
; lpszFont : LPCWSTR -> "wstr"
; lpszFile : LPCWSTR -> "wstr"
; lpszPath : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procCreateScalableFontResourceW = gdi32.NewProc("CreateScalableFontResourceW")
)

// fdwHidden (DWORD), lpszFont (LPCWSTR), lpszFile (LPCWSTR), lpszPath (LPCWSTR optional)
r1, _, err := procCreateScalableFontResourceW.Call(
	uintptr(fdwHidden),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszFont))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszFile))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszPath))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CreateScalableFontResourceW(
  fdwHidden: DWORD;   // DWORD
  lpszFont: PWideChar;   // LPCWSTR
  lpszFile: PWideChar;   // LPCWSTR
  lpszPath: PWideChar   // LPCWSTR optional
): BOOL; stdcall;
  external 'GDI32.dll' name 'CreateScalableFontResourceW';
result := DllCall("GDI32\CreateScalableFontResourceW"
    , "UInt", fdwHidden   ; DWORD
    , "WStr", lpszFont   ; LPCWSTR
    , "WStr", lpszFile   ; LPCWSTR
    , "WStr", lpszPath   ; LPCWSTR optional
    , "Int")   ; return: BOOL
●CreateScalableFontResourceW(fdwHidden, lpszFont, lpszFile, lpszPath) = DLL("GDI32.dll", "bool CreateScalableFontResourceW(dword, char*, char*, char*)")
# 呼び出し: CreateScalableFontResourceW(fdwHidden, lpszFont, lpszFile, lpszPath)
# fdwHidden : DWORD -> "dword"
# lpszFont : LPCWSTR -> "char*"
# lpszFile : LPCWSTR -> "char*"
# lpszPath : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。