ホーム › Globalization › ScriptFreeCache
ScriptFreeCache
関数Uniscribeのスクリプトキャッシュを解放する。
シグネチャ
// USP10.dll
#include <windows.h>
HRESULT ScriptFreeCache(
void** psc
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| psc | void** | inout | SCRIPT_CACHE 構造体へのポインター。 |
戻り値の型: HRESULT
公式ドキュメント
スクリプトキャッシュを解放します。
戻り値
成功した場合は 0 を返します。成功しなかった場合は、関数は 0 以外の HRESULT 値を返します。アプリケーションは、戻り値を SUCCEEDED および FAILED マクロでテストできます。
解説(Remarks)
アプリケーションはいつでもスクリプトキャッシュを解放できますが、アプリケーションがマルチスレッドの場合は一定の制限があります。Uniscribe はフォントキャッシュおよびシェイパーキャッシュで参照カウントを保持し、そのフォントのすべてのサイズが解放されたときにのみフォントデータを解放します。サポートされるすべてのフォントが解放されたときにのみシェイパーデータを解放します。
アプリケーションは、あるスタイルを破棄するときに、そのスタイルのスクリプトキャッシュを解放してください。
ScriptFreeCache は、誤った参照を回避するために、常にパラメーターを NULL に設定します。
Uniscribe 関数はリエントラントです。キャッシュの作成は、プロセス全体で 1 つのセマフォによってインターロックされます。ScriptFreeCache は、別のスレッドが解放対象の特定のキャッシュにアクセスしている可能性があるときに呼び出すべきではありません。パフォーマンス上の理由から、ScriptShape または ScriptPlace の実行中、キャッシュはロックされません。
重要 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 ScriptFreeCache(
void** psc
);[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptFreeCache(
IntPtr psc // void** in/out
);<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptFreeCache(
psc As IntPtr ' void** in/out
) As Integer
End Function' psc : void** in/out
Declare PtrSafe Function ScriptFreeCache Lib "usp10" ( _
ByVal psc As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ScriptFreeCache = ctypes.windll.usp10.ScriptFreeCache
ScriptFreeCache.restype = ctypes.c_int
ScriptFreeCache.argtypes = [
ctypes.c_void_p, # psc : void** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USP10.dll')
ScriptFreeCache = Fiddle::Function.new(
lib['ScriptFreeCache'],
[
Fiddle::TYPE_VOIDP, # psc : void** in/out
],
Fiddle::TYPE_INT)#[link(name = "usp10")]
extern "system" {
fn ScriptFreeCache(
psc: *mut *mut () // void** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptFreeCache(IntPtr psc);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptFreeCache' -Namespace Win32 -PassThru
# $api::ScriptFreeCache(psc)#uselib "USP10.dll"
#func global ScriptFreeCache "ScriptFreeCache" sptr
; ScriptFreeCache psc ; 戻り値は stat
; psc : void** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USP10.dll"
#cfunc global ScriptFreeCache "ScriptFreeCache" sptr
; res = ScriptFreeCache(psc)
; psc : void** in/out -> "sptr"; HRESULT ScriptFreeCache(void** psc)
#uselib "USP10.dll"
#cfunc global ScriptFreeCache "ScriptFreeCache" intptr
; res = ScriptFreeCache(psc)
; psc : void** in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
usp10 = windows.NewLazySystemDLL("USP10.dll")
procScriptFreeCache = usp10.NewProc("ScriptFreeCache")
)
// psc (void** in/out)
r1, _, err := procScriptFreeCache.Call(
uintptr(psc),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ScriptFreeCache(
psc: Pointer // void** in/out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptFreeCache';result := DllCall("USP10\ScriptFreeCache"
, "Ptr", psc ; void** in/out
, "Int") ; return: HRESULT●ScriptFreeCache(psc) = DLL("USP10.dll", "int ScriptFreeCache(void*)")
# 呼び出し: ScriptFreeCache(psc)
# psc : void** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "usp10" fn ScriptFreeCache(
psc: ?*anyopaque // void** in/out
) callconv(std.os.windows.WINAPI) i32;proc ScriptFreeCache(
psc: pointer # void** in/out
): int32 {.importc: "ScriptFreeCache", stdcall, dynlib: "USP10.dll".}pragma(lib, "usp10");
extern(Windows)
int ScriptFreeCache(
void** psc // void** in/out
);ccall((:ScriptFreeCache, "USP10.dll"), stdcall, Int32,
(Ptr{Cvoid},),
psc)
# psc : void** in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ScriptFreeCache(
void** psc);
]]
local usp10 = ffi.load("usp10")
-- usp10.ScriptFreeCache(psc)
-- psc : void** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USP10.dll');
const ScriptFreeCache = lib.func('__stdcall', 'ScriptFreeCache', 'int32_t', ['void *']);
// ScriptFreeCache(psc)
// psc : void** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USP10.dll", {
ScriptFreeCache: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.ScriptFreeCache(psc)
// psc : void** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ScriptFreeCache(
void** psc);
C, "USP10.dll");
// $ffi->ScriptFreeCache(psc);
// psc : void** in/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 ScriptFreeCache(
Pointer psc // void** in/out
);
}@[Link("usp10")]
lib LibUSP10
fun ScriptFreeCache = ScriptFreeCache(
psc : Void** # void** in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ScriptFreeCacheNative = Int32 Function(Pointer<Void>);
typedef ScriptFreeCacheDart = int Function(Pointer<Void>);
final ScriptFreeCache = DynamicLibrary.open('USP10.dll')
.lookupFunction<ScriptFreeCacheNative, ScriptFreeCacheDart>('ScriptFreeCache');
// psc : void** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ScriptFreeCache(
psc: Pointer // void** in/out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptFreeCache';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ScriptFreeCache"
c_ScriptFreeCache :: Ptr () -> IO Int32
-- psc : void** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let scriptfreecache =
foreign "ScriptFreeCache"
((ptr void) @-> returning int32_t)
(* psc : void** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library usp10 (t "USP10.dll"))
(cffi:use-foreign-library usp10)
(cffi:defcfun ("ScriptFreeCache" script-free-cache :convention :stdcall) :int32
(psc :pointer)) ; void** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ScriptFreeCache = Win32::API::More->new('USP10',
'int ScriptFreeCache(LPVOID psc)');
# my $ret = $ScriptFreeCache->Call($psc);
# psc : void** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。