ホーム › Globalization › ScriptCacheGetHeight
ScriptCacheGetHeight
関数スクリプトキャッシュからフォントの高さを取得する。
シグネチャ
// USP10.dll
#include <windows.h>
HRESULT ScriptCacheGetHeight(
HDC hdc,
void** psc,
INT* tmHeight
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | 省略可能。デバイスコンテキストへのハンドルです。詳細については、Caching を参照してください。 |
| psc | void** | inout | スクリプトキャッシュを識別する SCRIPT_CACHE 構造体へのポインターです。 |
| tmHeight | INT* | out | 関数がフォントの高さを取得して格納するバッファーへのポインターです。 |
戻り値の型: HRESULT
公式ドキュメント
現在キャッシュされているフォントの高さを取得します。
戻り値
成功した場合は 0 を返します。成功しなかった場合、関数は 0 以外の HRESULT 値を返します。アプリケーションは、SUCCEEDED マクロおよび FAILED マクロを使用して戻り値をテストできます。
解説(Remarks)
重要 Windows 8 以降: Windows 7 上で実行できる状態を維持するには、Uniscribe を使用するモジュールはライブラリ一覧で gdi32.lib より前に Usp10.lib を指定する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USP10.dll
#include <windows.h>
HRESULT ScriptCacheGetHeight(
HDC hdc,
void** psc,
INT* tmHeight
);[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptCacheGetHeight(
IntPtr hdc, // HDC
IntPtr psc, // void** in/out
out int tmHeight // INT* out
);<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptCacheGetHeight(
hdc As IntPtr, ' HDC
psc As IntPtr, ' void** in/out
<Out> ByRef tmHeight As Integer ' INT* out
) As Integer
End Function' hdc : HDC
' psc : void** in/out
' tmHeight : INT* out
Declare PtrSafe Function ScriptCacheGetHeight Lib "usp10" ( _
ByVal hdc As LongPtr, _
ByVal psc As LongPtr, _
ByRef tmHeight As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ScriptCacheGetHeight = ctypes.windll.usp10.ScriptCacheGetHeight
ScriptCacheGetHeight.restype = ctypes.c_int
ScriptCacheGetHeight.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # psc : void** in/out
ctypes.POINTER(ctypes.c_int), # tmHeight : INT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USP10.dll')
ScriptCacheGetHeight = Fiddle::Function.new(
lib['ScriptCacheGetHeight'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # psc : void** in/out
Fiddle::TYPE_VOIDP, # tmHeight : INT* out
],
Fiddle::TYPE_INT)#[link(name = "usp10")]
extern "system" {
fn ScriptCacheGetHeight(
hdc: *mut core::ffi::c_void, // HDC
psc: *mut *mut (), // void** in/out
tmHeight: *mut i32 // INT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptCacheGetHeight(IntPtr hdc, IntPtr psc, out int tmHeight);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptCacheGetHeight' -Namespace Win32 -PassThru
# $api::ScriptCacheGetHeight(hdc, psc, tmHeight)#uselib "USP10.dll"
#func global ScriptCacheGetHeight "ScriptCacheGetHeight" sptr, sptr, sptr
; ScriptCacheGetHeight hdc, psc, varptr(tmHeight) ; 戻り値は stat
; hdc : HDC -> "sptr"
; psc : void** in/out -> "sptr"
; tmHeight : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USP10.dll" #cfunc global ScriptCacheGetHeight "ScriptCacheGetHeight" sptr, sptr, var ; res = ScriptCacheGetHeight(hdc, psc, tmHeight) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; tmHeight : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USP10.dll" #cfunc global ScriptCacheGetHeight "ScriptCacheGetHeight" sptr, sptr, sptr ; res = ScriptCacheGetHeight(hdc, psc, varptr(tmHeight)) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; tmHeight : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT ScriptCacheGetHeight(HDC hdc, void** psc, INT* tmHeight) #uselib "USP10.dll" #cfunc global ScriptCacheGetHeight "ScriptCacheGetHeight" intptr, intptr, var ; res = ScriptCacheGetHeight(hdc, psc, tmHeight) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; tmHeight : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ScriptCacheGetHeight(HDC hdc, void** psc, INT* tmHeight) #uselib "USP10.dll" #cfunc global ScriptCacheGetHeight "ScriptCacheGetHeight" intptr, intptr, intptr ; res = ScriptCacheGetHeight(hdc, psc, varptr(tmHeight)) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; tmHeight : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
usp10 = windows.NewLazySystemDLL("USP10.dll")
procScriptCacheGetHeight = usp10.NewProc("ScriptCacheGetHeight")
)
// hdc (HDC), psc (void** in/out), tmHeight (INT* out)
r1, _, err := procScriptCacheGetHeight.Call(
uintptr(hdc),
uintptr(psc),
uintptr(tmHeight),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ScriptCacheGetHeight(
hdc: THandle; // HDC
psc: Pointer; // void** in/out
tmHeight: Pointer // INT* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptCacheGetHeight';result := DllCall("USP10\ScriptCacheGetHeight"
, "Ptr", hdc ; HDC
, "Ptr", psc ; void** in/out
, "Ptr", tmHeight ; INT* out
, "Int") ; return: HRESULT●ScriptCacheGetHeight(hdc, psc, tmHeight) = DLL("USP10.dll", "int ScriptCacheGetHeight(void*, void*, void*)")
# 呼び出し: ScriptCacheGetHeight(hdc, psc, tmHeight)
# hdc : HDC -> "void*"
# psc : void** in/out -> "void*"
# tmHeight : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "usp10" fn ScriptCacheGetHeight(
hdc: ?*anyopaque, // HDC
psc: ?*anyopaque, // void** in/out
tmHeight: [*c]i32 // INT* out
) callconv(std.os.windows.WINAPI) i32;proc ScriptCacheGetHeight(
hdc: pointer, # HDC
psc: pointer, # void** in/out
tmHeight: ptr int32 # INT* out
): int32 {.importc: "ScriptCacheGetHeight", stdcall, dynlib: "USP10.dll".}pragma(lib, "usp10");
extern(Windows)
int ScriptCacheGetHeight(
void* hdc, // HDC
void** psc, // void** in/out
int* tmHeight // INT* out
);ccall((:ScriptCacheGetHeight, "USP10.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Int32}),
hdc, psc, tmHeight)
# hdc : HDC -> Ptr{Cvoid}
# psc : void** in/out -> Ptr{Cvoid}
# tmHeight : INT* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ScriptCacheGetHeight(
void* hdc,
void** psc,
int32_t* tmHeight);
]]
local usp10 = ffi.load("usp10")
-- usp10.ScriptCacheGetHeight(hdc, psc, tmHeight)
-- hdc : HDC
-- psc : void** in/out
-- tmHeight : INT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USP10.dll');
const ScriptCacheGetHeight = lib.func('__stdcall', 'ScriptCacheGetHeight', 'int32_t', ['void *', 'void *', 'int32_t *']);
// ScriptCacheGetHeight(hdc, psc, tmHeight)
// hdc : HDC -> 'void *'
// psc : void** in/out -> 'void *'
// tmHeight : INT* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USP10.dll", {
ScriptCacheGetHeight: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ScriptCacheGetHeight(hdc, psc, tmHeight)
// hdc : HDC -> "pointer"
// psc : void** in/out -> "pointer"
// tmHeight : INT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ScriptCacheGetHeight(
void* hdc,
void** psc,
int32_t* tmHeight);
C, "USP10.dll");
// $ffi->ScriptCacheGetHeight(hdc, psc, tmHeight);
// hdc : HDC
// psc : void** in/out
// tmHeight : INT* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Usp10 extends StdCallLibrary {
Usp10 INSTANCE = Native.load("usp10", Usp10.class);
int ScriptCacheGetHeight(
Pointer hdc, // HDC
Pointer psc, // void** in/out
IntByReference tmHeight // INT* out
);
}@[Link("usp10")]
lib LibUSP10
fun ScriptCacheGetHeight = ScriptCacheGetHeight(
hdc : Void*, # HDC
psc : Void**, # void** in/out
tmHeight : Int32* # INT* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ScriptCacheGetHeightNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Int32>);
typedef ScriptCacheGetHeightDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Int32>);
final ScriptCacheGetHeight = DynamicLibrary.open('USP10.dll')
.lookupFunction<ScriptCacheGetHeightNative, ScriptCacheGetHeightDart>('ScriptCacheGetHeight');
// hdc : HDC -> Pointer<Void>
// psc : void** in/out -> Pointer<Void>
// tmHeight : INT* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ScriptCacheGetHeight(
hdc: THandle; // HDC
psc: Pointer; // void** in/out
tmHeight: Pointer // INT* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptCacheGetHeight';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ScriptCacheGetHeight"
c_ScriptCacheGetHeight :: Ptr () -> Ptr () -> Ptr Int32 -> IO Int32
-- hdc : HDC -> Ptr ()
-- psc : void** in/out -> Ptr ()
-- tmHeight : INT* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let scriptcachegetheight =
foreign "ScriptCacheGetHeight"
((ptr void) @-> (ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* psc : void** in/out -> (ptr void) *)
(* tmHeight : INT* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library usp10 (t "USP10.dll"))
(cffi:use-foreign-library usp10)
(cffi:defcfun ("ScriptCacheGetHeight" script-cache-get-height :convention :stdcall) :int32
(hdc :pointer) ; HDC
(psc :pointer) ; void** in/out
(tm-height :pointer)) ; INT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ScriptCacheGetHeight = Win32::API::More->new('USP10',
'int ScriptCacheGetHeight(HANDLE hdc, LPVOID psc, LPVOID tmHeight)');
# my $ret = $ScriptCacheGetHeight->Call($hdc, $psc, $tmHeight);
# hdc : HDC -> HANDLE
# psc : void** in/out -> LPVOID
# tmHeight : INT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。