ホーム › Globalization › ScriptGetCMap
ScriptGetCMap
関数文字に対応するフォントのグリフインデックスを取得する。
シグネチャ
// USP10.dll
#include <windows.h>
HRESULT ScriptGetCMap(
HDC hdc,
void** psc,
LPCWSTR pwcInChars,
INT cChars,
DWORD dwFlags,
WORD* pwOutGlyphs
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| psc | void** | inout |
| pwcInChars | LPCWSTR | in |
| cChars | INT | in |
| dwFlags | DWORD | in |
| pwOutGlyphs | WORD* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// USP10.dll
#include <windows.h>
HRESULT ScriptGetCMap(
HDC hdc,
void** psc,
LPCWSTR pwcInChars,
INT cChars,
DWORD dwFlags,
WORD* pwOutGlyphs
);[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptGetCMap(
IntPtr hdc, // HDC
IntPtr psc, // void** in/out
[MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, // LPCWSTR
int cChars, // INT
uint dwFlags, // DWORD
out ushort pwOutGlyphs // WORD* out
);<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptGetCMap(
hdc As IntPtr, ' HDC
psc As IntPtr, ' void** in/out
<MarshalAs(UnmanagedType.LPWStr)> pwcInChars As String, ' LPCWSTR
cChars As Integer, ' INT
dwFlags As UInteger, ' DWORD
<Out> ByRef pwOutGlyphs As UShort ' WORD* out
) As Integer
End Function' hdc : HDC
' psc : void** in/out
' pwcInChars : LPCWSTR
' cChars : INT
' dwFlags : DWORD
' pwOutGlyphs : WORD* out
Declare PtrSafe Function ScriptGetCMap Lib "usp10" ( _
ByVal hdc As LongPtr, _
ByVal psc As LongPtr, _
ByVal pwcInChars As LongPtr, _
ByVal cChars As Long, _
ByVal dwFlags As Long, _
ByRef pwOutGlyphs As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ScriptGetCMap = ctypes.windll.usp10.ScriptGetCMap
ScriptGetCMap.restype = ctypes.c_int
ScriptGetCMap.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # psc : void** in/out
wintypes.LPCWSTR, # pwcInChars : LPCWSTR
ctypes.c_int, # cChars : INT
wintypes.DWORD, # dwFlags : DWORD
ctypes.POINTER(ctypes.c_ushort), # pwOutGlyphs : WORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USP10.dll')
ScriptGetCMap = Fiddle::Function.new(
lib['ScriptGetCMap'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # psc : void** in/out
Fiddle::TYPE_VOIDP, # pwcInChars : LPCWSTR
Fiddle::TYPE_INT, # cChars : INT
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # pwOutGlyphs : WORD* out
],
Fiddle::TYPE_INT)#[link(name = "usp10")]
extern "system" {
fn ScriptGetCMap(
hdc: *mut core::ffi::c_void, // HDC
psc: *mut *mut (), // void** in/out
pwcInChars: *const u16, // LPCWSTR
cChars: i32, // INT
dwFlags: u32, // DWORD
pwOutGlyphs: *mut u16 // WORD* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptGetCMap(IntPtr hdc, IntPtr psc, [MarshalAs(UnmanagedType.LPWStr)] string pwcInChars, int cChars, uint dwFlags, out ushort pwOutGlyphs);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptGetCMap' -Namespace Win32 -PassThru
# $api::ScriptGetCMap(hdc, psc, pwcInChars, cChars, dwFlags, pwOutGlyphs)#uselib "USP10.dll"
#func global ScriptGetCMap "ScriptGetCMap" sptr, sptr, sptr, sptr, sptr, sptr
; ScriptGetCMap hdc, psc, pwcInChars, cChars, dwFlags, varptr(pwOutGlyphs) ; 戻り値は stat
; hdc : HDC -> "sptr"
; psc : void** in/out -> "sptr"
; pwcInChars : LPCWSTR -> "sptr"
; cChars : INT -> "sptr"
; dwFlags : DWORD -> "sptr"
; pwOutGlyphs : WORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USP10.dll" #cfunc global ScriptGetCMap "ScriptGetCMap" sptr, sptr, wstr, int, int, var ; res = ScriptGetCMap(hdc, psc, pwcInChars, cChars, dwFlags, pwOutGlyphs) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; pwcInChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; dwFlags : DWORD -> "int" ; pwOutGlyphs : WORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USP10.dll" #cfunc global ScriptGetCMap "ScriptGetCMap" sptr, sptr, wstr, int, int, sptr ; res = ScriptGetCMap(hdc, psc, pwcInChars, cChars, dwFlags, varptr(pwOutGlyphs)) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; pwcInChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; dwFlags : DWORD -> "int" ; pwOutGlyphs : WORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT ScriptGetCMap(HDC hdc, void** psc, LPCWSTR pwcInChars, INT cChars, DWORD dwFlags, WORD* pwOutGlyphs) #uselib "USP10.dll" #cfunc global ScriptGetCMap "ScriptGetCMap" intptr, intptr, wstr, int, int, var ; res = ScriptGetCMap(hdc, psc, pwcInChars, cChars, dwFlags, pwOutGlyphs) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; pwcInChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; dwFlags : DWORD -> "int" ; pwOutGlyphs : WORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ScriptGetCMap(HDC hdc, void** psc, LPCWSTR pwcInChars, INT cChars, DWORD dwFlags, WORD* pwOutGlyphs) #uselib "USP10.dll" #cfunc global ScriptGetCMap "ScriptGetCMap" intptr, intptr, wstr, int, int, intptr ; res = ScriptGetCMap(hdc, psc, pwcInChars, cChars, dwFlags, varptr(pwOutGlyphs)) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; pwcInChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; dwFlags : DWORD -> "int" ; pwOutGlyphs : WORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
usp10 = windows.NewLazySystemDLL("USP10.dll")
procScriptGetCMap = usp10.NewProc("ScriptGetCMap")
)
// hdc (HDC), psc (void** in/out), pwcInChars (LPCWSTR), cChars (INT), dwFlags (DWORD), pwOutGlyphs (WORD* out)
r1, _, err := procScriptGetCMap.Call(
uintptr(hdc),
uintptr(psc),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwcInChars))),
uintptr(cChars),
uintptr(dwFlags),
uintptr(pwOutGlyphs),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ScriptGetCMap(
hdc: THandle; // HDC
psc: Pointer; // void** in/out
pwcInChars: PWideChar; // LPCWSTR
cChars: Integer; // INT
dwFlags: DWORD; // DWORD
pwOutGlyphs: Pointer // WORD* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptGetCMap';result := DllCall("USP10\ScriptGetCMap"
, "Ptr", hdc ; HDC
, "Ptr", psc ; void** in/out
, "WStr", pwcInChars ; LPCWSTR
, "Int", cChars ; INT
, "UInt", dwFlags ; DWORD
, "Ptr", pwOutGlyphs ; WORD* out
, "Int") ; return: HRESULT●ScriptGetCMap(hdc, psc, pwcInChars, cChars, dwFlags, pwOutGlyphs) = DLL("USP10.dll", "int ScriptGetCMap(void*, void*, char*, int, dword, void*)")
# 呼び出し: ScriptGetCMap(hdc, psc, pwcInChars, cChars, dwFlags, pwOutGlyphs)
# hdc : HDC -> "void*"
# psc : void** in/out -> "void*"
# pwcInChars : LPCWSTR -> "char*"
# cChars : INT -> "int"
# dwFlags : DWORD -> "dword"
# pwOutGlyphs : WORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。