Win32 API 日本語リファレンス
ホームGlobalization › uldn_getContext

uldn_getContext

関数
表示名生成オブジェクトの表示コンテキストを取得する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

UDisplayContext uldn_getContext(
    const ULocaleDisplayNames* ldn,
    UDisplayContextType type,
    UErrorCode* pErrorCode
);

パラメーター

名前方向説明
ldnULocaleDisplayNames*in対象のロケール表示名オブジェクト。
typeUDisplayContextTypein値を取得したい表示文脈の種別を示すUDisplayContextType。
pErrorCodeUErrorCode*inoutICUエラーコードを受け渡すポインタ。U_ZERO_ERRORへ初期化が必要。

戻り値の型: UDisplayContext

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

UDisplayContext uldn_getContext(
    const ULocaleDisplayNames* ldn,
    UDisplayContextType type,
    UErrorCode* pErrorCode
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int uldn_getContext(
    ref IntPtr ldn,   // ULocaleDisplayNames*
    int type,   // UDisplayContextType
    ref int pErrorCode   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function uldn_getContext(
    ByRef ldn As IntPtr,   ' ULocaleDisplayNames*
    type As Integer,   ' UDisplayContextType
    ByRef pErrorCode As Integer   ' UErrorCode* in/out
) As Integer
End Function
' ldn : ULocaleDisplayNames*
' type : UDisplayContextType
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function uldn_getContext Lib "icuuc" ( _
    ByRef ldn As LongPtr, _
    ByVal type As Long, _
    ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

uldn_getContext = ctypes.cdll.icuuc.uldn_getContext
uldn_getContext.restype = ctypes.c_int
uldn_getContext.argtypes = [
    ctypes.c_void_p,  # ldn : ULocaleDisplayNames*
    ctypes.c_int,  # type : UDisplayContextType
    ctypes.c_void_p,  # pErrorCode : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
uldn_getContext = Fiddle::Function.new(
  lib['uldn_getContext'],
  [
    Fiddle::TYPE_VOIDP,  # ldn : ULocaleDisplayNames*
    Fiddle::TYPE_INT,  # type : UDisplayContextType
    Fiddle::TYPE_VOIDP,  # pErrorCode : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn uldn_getContext(
        ldn: *const isize,  // ULocaleDisplayNames*
        type: i32,  // UDisplayContextType
        pErrorCode: *mut i32  // UErrorCode* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int uldn_getContext(ref IntPtr ldn, int type, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_uldn_getContext' -Namespace Win32 -PassThru
# $api::uldn_getContext(ldn, type, pErrorCode)
#uselib "icuuc.dll"
#func global uldn_getContext "uldn_getContext" sptr, sptr, sptr
; uldn_getContext varptr(ldn), type, varptr(pErrorCode)   ; 戻り値は stat
; ldn : ULocaleDisplayNames* -> "sptr"
; type : UDisplayContextType -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global uldn_getContext "uldn_getContext" var, int, var
; res = uldn_getContext(ldn, type, pErrorCode)
; ldn : ULocaleDisplayNames* -> "var"
; type : UDisplayContextType -> "int"
; pErrorCode : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; UDisplayContext uldn_getContext(ULocaleDisplayNames* ldn, UDisplayContextType type, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global uldn_getContext "uldn_getContext" var, int, var
; res = uldn_getContext(ldn, type, pErrorCode)
; ldn : ULocaleDisplayNames* -> "var"
; type : UDisplayContextType -> "int"
; pErrorCode : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	proculdn_getContext = icuuc.NewProc("uldn_getContext")
)

// ldn (ULocaleDisplayNames*), type (UDisplayContextType), pErrorCode (UErrorCode* in/out)
r1, _, err := proculdn_getContext.Call(
	uintptr(ldn),
	uintptr(type),
	uintptr(pErrorCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // UDisplayContext
function uldn_getContext(
  ldn: Pointer;   // ULocaleDisplayNames*
  type: Integer;   // UDisplayContextType
  pErrorCode: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'uldn_getContext';
result := DllCall("icuuc\uldn_getContext"
    , "Ptr", ldn   ; ULocaleDisplayNames*
    , "Int", type   ; UDisplayContextType
    , "Ptr", pErrorCode   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: UDisplayContext
●uldn_getContext(ldn, type, pErrorCode) = DLL("icuuc.dll", "int uldn_getContext(void*, int, void*)")
# 呼び出し: uldn_getContext(ldn, type, pErrorCode)
# ldn : ULocaleDisplayNames* -> "void*"
# type : UDisplayContextType -> "int"
# pErrorCode : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。
const std = @import("std");

extern "icuuc" fn uldn_getContext(
    ldn: [*c]isize, // ULocaleDisplayNames*
    type: i32, // UDisplayContextType
    pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;
proc uldn_getContext(
    ldn: ptr int,  # ULocaleDisplayNames*
    `type`: int32,  # UDisplayContextType
    pErrorCode: ptr int32  # UErrorCode* in/out
): int32 {.importc: "uldn_getContext", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
int uldn_getContext(
    ptrdiff_t* ldn,   // ULocaleDisplayNames*
    int type,   // UDisplayContextType
    int* pErrorCode   // UErrorCode* in/out
);
ccall((:uldn_getContext, "icuuc.dll"), Int32,
      (Ptr{Int}, Int32, Ptr{Int32}),
      ldn, type, pErrorCode)
# ldn : ULocaleDisplayNames* -> Ptr{Int}
# type : UDisplayContextType -> Int32
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
int32_t uldn_getContext(
    intptr_t* ldn,
    int32_t type,
    int32_t* pErrorCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.uldn_getContext(ldn, type, pErrorCode)
-- ldn : ULocaleDisplayNames*
-- type : UDisplayContextType
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const uldn_getContext = lib.func('__cdecl', 'uldn_getContext', 'int32_t', ['intptr_t *', 'int32_t', 'int32_t *']);
// uldn_getContext(ldn, type, pErrorCode)
// ldn : ULocaleDisplayNames* -> 'intptr_t *'
// type : UDisplayContextType -> 'int32_t'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  uldn_getContext: { parameters: ["pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.uldn_getContext(ldn, type, pErrorCode)
// ldn : ULocaleDisplayNames* -> "pointer"
// type : UDisplayContextType -> "i32"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t uldn_getContext(
    intptr_t* ldn,
    int32_t type,
    int32_t* pErrorCode);
C, "icuuc.dll");
// $ffi->uldn_getContext(ldn, type, pErrorCode);
// ldn : ULocaleDisplayNames*
// type : UDisplayContextType
// pErrorCode : UErrorCode* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Icuuc extends Library {
    Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
    int uldn_getContext(
        LongByReference ldn,   // ULocaleDisplayNames*
        int type,   // UDisplayContextType
        IntByReference pErrorCode   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun uldn_getContext = uldn_getContext(
    ldn : LibC::SSizeT*,   # ULocaleDisplayNames*
    type_ : Int32,   # UDisplayContextType
    pErrorCode : Int32*   # UErrorCode* in/out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef uldn_getContextNative = Int32 Function(Pointer<IntPtr>, Int32, Pointer<Int32>);
typedef uldn_getContextDart = int Function(Pointer<IntPtr>, int, Pointer<Int32>);
final uldn_getContext = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<uldn_getContextNative, uldn_getContextDart>('uldn_getContext');
// ldn : ULocaleDisplayNames* -> Pointer<IntPtr>
// type : UDisplayContextType -> Int32
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function uldn_getContext(
  ldn: Pointer;   // ULocaleDisplayNames*
  type: Integer;   // UDisplayContextType
  pErrorCode: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'uldn_getContext';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "uldn_getContext"
  c_uldn_getContext :: Ptr CIntPtr -> Int32 -> Ptr Int32 -> IO Int32
-- ldn : ULocaleDisplayNames* -> Ptr CIntPtr
-- type : UDisplayContextType -> Int32
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let uldn_getcontext =
  foreign "uldn_getContext"
    ((ptr intptr_t) @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* ldn : ULocaleDisplayNames* -> (ptr intptr_t) *)
(* type : UDisplayContextType -> int32_t *)
(* pErrorCode : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)

(cffi:defcfun ("uldn_getContext" uldn-get-context :convention :cdecl) :int32
  (ldn :pointer)   ; ULocaleDisplayNames*
  (type :int32)   ; UDisplayContextType
  (p-error-code :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $uldn_getContext = Win32::API::More->new('icuuc',
    'int uldn_getContext(LPVOID ldn, int type, LPVOID pErrorCode)');
# my $ret = $uldn_getContext->Call($ldn, $type, $pErrorCode);
# ldn : ULocaleDisplayNames* -> LPVOID
# type : UDisplayContextType -> int
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型