ホーム › System.Ole › OleCreateFontIndirect
OleCreateFontIndirect
関数フォント記述子からOLEフォントオブジェクトを作成する。
シグネチャ
// OLEAUT32.dll
#include <windows.h>
HRESULT OleCreateFontIndirect(
FONTDESC* lpFontDesc,
const GUID* riid,
void** lplpvObj
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpFontDesc | FONTDESC* | in | フォントの初期状態を格納した、呼び出し側が割り当てた FONTDESC 構造体のアドレス。この値は NULL であってはなりません。 |
| riid | GUID* | in | lplpvObj で返すインターフェイスポインターの種類を記述するインターフェイスの識別子への参照。 |
| lplpvObj | void** | out | riid で要求されたインターフェイスポインターを受け取るポインター変数のアドレス。正常に終了した場合、このパラメーターには新しく作成されたフォントオブジェクトの要求されたインターフェイスポインターが格納されます。成功した場合、呼び出し側は新しいオブジェクトが不要になったときに、このインターフェイスポインターを通じて Release を呼び出す責任があります。失敗した場合、値は NULL に設定されます。 |
戻り値の型: HRESULT
公式ドキュメント
FONTDESC 構造体によるフォントのプロパティの初期記述を使用して、標準フォントオブジェクトを作成および初期化します。
戻り値
この関数は成功すると S_OK を返します。その他に返される可能性のある値は以下のとおりです。
| 戻り値 | 説明 |
|---|---|
| 指定されたインターフェイス識別子が無効です。 | |
| 予期しないエラーが発生しました。 | |
| 操作に必要なメモリが不足しています。 | |
| 1 つ以上のパラメーターが無効です。 | |
| pFontDesc または ppvObj のアドレスが無効です。pFontDesc が NULL に設定されている場合、この関数は NO_ERROR を返すことに注意してください。 |
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// OLEAUT32.dll
#include <windows.h>
HRESULT OleCreateFontIndirect(
FONTDESC* lpFontDesc,
const GUID* riid,
void** lplpvObj
);[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int OleCreateFontIndirect(
IntPtr lpFontDesc, // FONTDESC*
ref Guid riid, // GUID*
IntPtr lplpvObj // void** out
);<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function OleCreateFontIndirect(
lpFontDesc As IntPtr, ' FONTDESC*
ByRef riid As Guid, ' GUID*
lplpvObj As IntPtr ' void** out
) As Integer
End Function' lpFontDesc : FONTDESC*
' riid : GUID*
' lplpvObj : void** out
Declare PtrSafe Function OleCreateFontIndirect Lib "oleaut32" ( _
ByVal lpFontDesc As LongPtr, _
ByVal riid As LongPtr, _
ByVal lplpvObj As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OleCreateFontIndirect = ctypes.windll.oleaut32.OleCreateFontIndirect
OleCreateFontIndirect.restype = ctypes.c_int
OleCreateFontIndirect.argtypes = [
ctypes.c_void_p, # lpFontDesc : FONTDESC*
ctypes.c_void_p, # riid : GUID*
ctypes.c_void_p, # lplpvObj : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLEAUT32.dll')
OleCreateFontIndirect = Fiddle::Function.new(
lib['OleCreateFontIndirect'],
[
Fiddle::TYPE_VOIDP, # lpFontDesc : FONTDESC*
Fiddle::TYPE_VOIDP, # riid : GUID*
Fiddle::TYPE_VOIDP, # lplpvObj : void** out
],
Fiddle::TYPE_INT)#[link(name = "oleaut32")]
extern "system" {
fn OleCreateFontIndirect(
lpFontDesc: *mut FONTDESC, // FONTDESC*
riid: *const GUID, // GUID*
lplpvObj: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern int OleCreateFontIndirect(IntPtr lpFontDesc, ref Guid riid, IntPtr lplpvObj);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_OleCreateFontIndirect' -Namespace Win32 -PassThru
# $api::OleCreateFontIndirect(lpFontDesc, riid, lplpvObj)#uselib "OLEAUT32.dll"
#func global OleCreateFontIndirect "OleCreateFontIndirect" sptr, sptr, sptr
; OleCreateFontIndirect varptr(lpFontDesc), varptr(riid), lplpvObj ; 戻り値は stat
; lpFontDesc : FONTDESC* -> "sptr"
; riid : GUID* -> "sptr"
; lplpvObj : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLEAUT32.dll" #cfunc global OleCreateFontIndirect "OleCreateFontIndirect" var, var, sptr ; res = OleCreateFontIndirect(lpFontDesc, riid, lplpvObj) ; lpFontDesc : FONTDESC* -> "var" ; riid : GUID* -> "var" ; lplpvObj : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLEAUT32.dll" #cfunc global OleCreateFontIndirect "OleCreateFontIndirect" sptr, sptr, sptr ; res = OleCreateFontIndirect(varptr(lpFontDesc), varptr(riid), lplpvObj) ; lpFontDesc : FONTDESC* -> "sptr" ; riid : GUID* -> "sptr" ; lplpvObj : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT OleCreateFontIndirect(FONTDESC* lpFontDesc, GUID* riid, void** lplpvObj) #uselib "OLEAUT32.dll" #cfunc global OleCreateFontIndirect "OleCreateFontIndirect" var, var, intptr ; res = OleCreateFontIndirect(lpFontDesc, riid, lplpvObj) ; lpFontDesc : FONTDESC* -> "var" ; riid : GUID* -> "var" ; lplpvObj : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT OleCreateFontIndirect(FONTDESC* lpFontDesc, GUID* riid, void** lplpvObj) #uselib "OLEAUT32.dll" #cfunc global OleCreateFontIndirect "OleCreateFontIndirect" intptr, intptr, intptr ; res = OleCreateFontIndirect(varptr(lpFontDesc), varptr(riid), lplpvObj) ; lpFontDesc : FONTDESC* -> "intptr" ; riid : GUID* -> "intptr" ; lplpvObj : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
procOleCreateFontIndirect = oleaut32.NewProc("OleCreateFontIndirect")
)
// lpFontDesc (FONTDESC*), riid (GUID*), lplpvObj (void** out)
r1, _, err := procOleCreateFontIndirect.Call(
uintptr(lpFontDesc),
uintptr(riid),
uintptr(lplpvObj),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction OleCreateFontIndirect(
lpFontDesc: Pointer; // FONTDESC*
riid: PGUID; // GUID*
lplpvObj: Pointer // void** out
): Integer; stdcall;
external 'OLEAUT32.dll' name 'OleCreateFontIndirect';result := DllCall("OLEAUT32\OleCreateFontIndirect"
, "Ptr", lpFontDesc ; FONTDESC*
, "Ptr", riid ; GUID*
, "Ptr", lplpvObj ; void** out
, "Int") ; return: HRESULT●OleCreateFontIndirect(lpFontDesc, riid, lplpvObj) = DLL("OLEAUT32.dll", "int OleCreateFontIndirect(void*, void*, void*)")
# 呼び出し: OleCreateFontIndirect(lpFontDesc, riid, lplpvObj)
# lpFontDesc : FONTDESC* -> "void*"
# riid : GUID* -> "void*"
# lplpvObj : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "oleaut32" fn OleCreateFontIndirect(
lpFontDesc: [*c]FONTDESC, // FONTDESC*
riid: [*c]GUID, // GUID*
lplpvObj: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc OleCreateFontIndirect(
lpFontDesc: ptr FONTDESC, # FONTDESC*
riid: ptr GUID, # GUID*
lplpvObj: pointer # void** out
): int32 {.importc: "OleCreateFontIndirect", stdcall, dynlib: "OLEAUT32.dll".}pragma(lib, "oleaut32");
extern(Windows)
int OleCreateFontIndirect(
FONTDESC* lpFontDesc, // FONTDESC*
GUID* riid, // GUID*
void** lplpvObj // void** out
);ccall((:OleCreateFontIndirect, "OLEAUT32.dll"), stdcall, Int32,
(Ptr{FONTDESC}, Ptr{GUID}, Ptr{Cvoid}),
lpFontDesc, riid, lplpvObj)
# lpFontDesc : FONTDESC* -> Ptr{FONTDESC}
# riid : GUID* -> Ptr{GUID}
# lplpvObj : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t OleCreateFontIndirect(
void* lpFontDesc,
void* riid,
void** lplpvObj);
]]
local oleaut32 = ffi.load("oleaut32")
-- oleaut32.OleCreateFontIndirect(lpFontDesc, riid, lplpvObj)
-- lpFontDesc : FONTDESC*
-- riid : GUID*
-- lplpvObj : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OLEAUT32.dll');
const OleCreateFontIndirect = lib.func('__stdcall', 'OleCreateFontIndirect', 'int32_t', ['void *', 'void *', 'void *']);
// OleCreateFontIndirect(lpFontDesc, riid, lplpvObj)
// lpFontDesc : FONTDESC* -> 'void *'
// riid : GUID* -> 'void *'
// lplpvObj : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OLEAUT32.dll", {
OleCreateFontIndirect: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.OleCreateFontIndirect(lpFontDesc, riid, lplpvObj)
// lpFontDesc : FONTDESC* -> "pointer"
// riid : GUID* -> "pointer"
// lplpvObj : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t OleCreateFontIndirect(
void* lpFontDesc,
void* riid,
void** lplpvObj);
C, "OLEAUT32.dll");
// $ffi->OleCreateFontIndirect(lpFontDesc, riid, lplpvObj);
// lpFontDesc : FONTDESC*
// riid : GUID*
// lplpvObj : void** 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 Oleaut32 extends StdCallLibrary {
Oleaut32 INSTANCE = Native.load("oleaut32", Oleaut32.class);
int OleCreateFontIndirect(
Pointer lpFontDesc, // FONTDESC*
Pointer riid, // GUID*
Pointer lplpvObj // void** out
);
}@[Link("oleaut32")]
lib LibOLEAUT32
fun OleCreateFontIndirect = OleCreateFontIndirect(
lpFontDesc : FONTDESC*, # FONTDESC*
riid : GUID*, # GUID*
lplpvObj : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef OleCreateFontIndirectNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef OleCreateFontIndirectDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final OleCreateFontIndirect = DynamicLibrary.open('OLEAUT32.dll')
.lookupFunction<OleCreateFontIndirectNative, OleCreateFontIndirectDart>('OleCreateFontIndirect');
// lpFontDesc : FONTDESC* -> Pointer<Void>
// riid : GUID* -> Pointer<Void>
// lplpvObj : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function OleCreateFontIndirect(
lpFontDesc: Pointer; // FONTDESC*
riid: PGUID; // GUID*
lplpvObj: Pointer // void** out
): Integer; stdcall;
external 'OLEAUT32.dll' name 'OleCreateFontIndirect';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OleCreateFontIndirect"
c_OleCreateFontIndirect :: Ptr () -> Ptr () -> Ptr () -> IO Int32
-- lpFontDesc : FONTDESC* -> Ptr ()
-- riid : GUID* -> Ptr ()
-- lplpvObj : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let olecreatefontindirect =
foreign "OleCreateFontIndirect"
((ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* lpFontDesc : FONTDESC* -> (ptr void) *)
(* riid : GUID* -> (ptr void) *)
(* lplpvObj : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library oleaut32 (t "OLEAUT32.dll"))
(cffi:use-foreign-library oleaut32)
(cffi:defcfun ("OleCreateFontIndirect" ole-create-font-indirect :convention :stdcall) :int32
(lp-font-desc :pointer) ; FONTDESC*
(riid :pointer) ; GUID*
(lplpv-obj :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $OleCreateFontIndirect = Win32::API::More->new('OLEAUT32',
'int OleCreateFontIndirect(LPVOID lpFontDesc, LPVOID riid, LPVOID lplpvObj)');
# my $ret = $OleCreateFontIndirect->Call($lpFontDesc, $riid, $lplpvObj);
# lpFontDesc : FONTDESC* -> LPVOID
# riid : GUID* -> LPVOID
# lplpvObj : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型