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

RemoveFontResourceW

関数
追加したフォントリソースをシステムから削除する。
DLLGDI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL RemoveFontResourceW(
    LPCWSTR lpFileName
);

パラメーター

名前方向
lpFileNameLPCWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL RemoveFontResourceW(
    LPCWSTR lpFileName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool RemoveFontResourceW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpFileName   // LPCWSTR
);
<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RemoveFontResourceW(
    <MarshalAs(UnmanagedType.LPWStr)> lpFileName As String   ' LPCWSTR
) As Boolean
End Function
' lpFileName : LPCWSTR
Declare PtrSafe Function RemoveFontResourceW Lib "gdi32" ( _
    ByVal lpFileName 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

RemoveFontResourceW = ctypes.windll.gdi32.RemoveFontResourceW
RemoveFontResourceW.restype = wintypes.BOOL
RemoveFontResourceW.argtypes = [
    wintypes.LPCWSTR,  # lpFileName : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procRemoveFontResourceW = gdi32.NewProc("RemoveFontResourceW")
)

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