Win32 API 日本語リファレンス
ホームUI.Input.Ime › ImmGetCompositionFontW

ImmGetCompositionFontW

関数
変換文字列に使うロゴフォント情報を取得する(Unicode版)。
DLLIMM32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL ImmGetCompositionFontW(
    HIMC param0,
    LOGFONTW* lplf
);

パラメーター

名前方向
param0HIMCin
lplfLOGFONTW*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ImmGetCompositionFontW(
    HIMC param0,
    LOGFONTW* lplf
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("IMM32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool ImmGetCompositionFontW(
    IntPtr param0,   // HIMC
    IntPtr lplf   // LOGFONTW* out
);
<DllImport("IMM32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function ImmGetCompositionFontW(
    param0 As IntPtr,   ' HIMC
    lplf As IntPtr   ' LOGFONTW* out
) As Boolean
End Function
' param0 : HIMC
' lplf : LOGFONTW* out
Declare PtrSafe Function ImmGetCompositionFontW Lib "imm32" ( _
    ByVal param0 As LongPtr, _
    ByVal lplf 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

ImmGetCompositionFontW = ctypes.windll.imm32.ImmGetCompositionFontW
ImmGetCompositionFontW.restype = wintypes.BOOL
ImmGetCompositionFontW.argtypes = [
    wintypes.HANDLE,  # param0 : HIMC
    ctypes.c_void_p,  # lplf : LOGFONTW* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('IMM32.dll')
ImmGetCompositionFontW = Fiddle::Function.new(
  lib['ImmGetCompositionFontW'],
  [
    Fiddle::TYPE_VOIDP,  # param0 : HIMC
    Fiddle::TYPE_VOIDP,  # lplf : LOGFONTW* out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "imm32")]
extern "system" {
    fn ImmGetCompositionFontW(
        param0: *mut core::ffi::c_void,  // HIMC
        lplf: *mut LOGFONTW  // LOGFONTW* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("IMM32.dll", CharSet = CharSet.Unicode)]
public static extern bool ImmGetCompositionFontW(IntPtr param0, IntPtr lplf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IMM32_ImmGetCompositionFontW' -Namespace Win32 -PassThru
# $api::ImmGetCompositionFontW(param0, lplf)
#uselib "IMM32.dll"
#func global ImmGetCompositionFontW "ImmGetCompositionFontW" wptr, wptr
; ImmGetCompositionFontW param0, varptr(lplf)   ; 戻り値は stat
; param0 : HIMC -> "wptr"
; lplf : LOGFONTW* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "IMM32.dll"
#cfunc global ImmGetCompositionFontW "ImmGetCompositionFontW" sptr, var
; res = ImmGetCompositionFontW(param0, lplf)
; param0 : HIMC -> "sptr"
; lplf : LOGFONTW* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL ImmGetCompositionFontW(HIMC param0, LOGFONTW* lplf)
#uselib "IMM32.dll"
#cfunc global ImmGetCompositionFontW "ImmGetCompositionFontW" intptr, var
; res = ImmGetCompositionFontW(param0, lplf)
; param0 : HIMC -> "intptr"
; lplf : LOGFONTW* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	imm32 = windows.NewLazySystemDLL("IMM32.dll")
	procImmGetCompositionFontW = imm32.NewProc("ImmGetCompositionFontW")
)

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