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

ures_getByKey

関数
リソースバンドルからキー指定で子リソースを取得する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

UResourceBundle* ures_getByKey(
    const UResourceBundle* resourceBundle,
    LPCSTR key,
    UResourceBundle* fillIn,
    UErrorCode* status
);

パラメーター

名前方向説明
resourceBundleUResourceBundle*in親となるリソースバンドル(テーブル)。
keyLPCSTRin取得する子リソースのキー名。
fillInUResourceBundle*inout結果を再利用して格納するバンドル。NULLなら新規確保する。
statusUErrorCode*inoutICUエラーコードを受け渡すポインタ。U_ZERO_ERRORへ初期化が必要。

戻り値の型: UResourceBundle*

各言語での呼び出し定義

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

UResourceBundle* ures_getByKey(
    const UResourceBundle* resourceBundle,
    LPCSTR key,
    UResourceBundle* fillIn,
    UErrorCode* status
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ures_getByKey(
    ref IntPtr resourceBundle,   // UResourceBundle*
    [MarshalAs(UnmanagedType.LPStr)] string key,   // LPCSTR
    ref IntPtr fillIn,   // UResourceBundle* in/out
    ref int status   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ures_getByKey(
    ByRef resourceBundle As IntPtr,   ' UResourceBundle*
    <MarshalAs(UnmanagedType.LPStr)> key As String,   ' LPCSTR
    ByRef fillIn As IntPtr,   ' UResourceBundle* in/out
    ByRef status As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' resourceBundle : UResourceBundle*
' key : LPCSTR
' fillIn : UResourceBundle* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function ures_getByKey Lib "icuuc" ( _
    ByRef resourceBundle As LongPtr, _
    ByVal key As String, _
    ByRef fillIn As LongPtr, _
    ByRef status As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ures_getByKey = ctypes.cdll.icuuc.ures_getByKey
ures_getByKey.restype = ctypes.c_void_p
ures_getByKey.argtypes = [
    ctypes.c_void_p,  # resourceBundle : UResourceBundle*
    wintypes.LPCSTR,  # key : LPCSTR
    ctypes.c_void_p,  # fillIn : UResourceBundle* in/out
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procures_getByKey = icuuc.NewProc("ures_getByKey")
)

// resourceBundle (UResourceBundle*), key (LPCSTR), fillIn (UResourceBundle* in/out), status (UErrorCode* in/out)
r1, _, err := procures_getByKey.Call(
	uintptr(resourceBundle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(key))),
	uintptr(fillIn),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // UResourceBundle*
function ures_getByKey(
  resourceBundle: Pointer;   // UResourceBundle*
  key: PAnsiChar;   // LPCSTR
  fillIn: Pointer;   // UResourceBundle* in/out
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'ures_getByKey';
result := DllCall("icuuc\ures_getByKey"
    , "Ptr", resourceBundle   ; UResourceBundle*
    , "AStr", key   ; LPCSTR
    , "Ptr", fillIn   ; UResourceBundle* in/out
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: UResourceBundle*
●ures_getByKey(resourceBundle, key, fillIn, status) = DLL("icuuc.dll", "void* ures_getByKey(void*, char*, void*, void*)")
# 呼び出し: ures_getByKey(resourceBundle, key, fillIn, status)
# resourceBundle : UResourceBundle* -> "void*"
# key : LPCSTR -> "char*"
# fillIn : UResourceBundle* in/out -> "void*"
# status : 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 ures_getByKey(
    resourceBundle: [*c]isize, // UResourceBundle*
    key: [*c]const u8, // LPCSTR
    fillIn: [*c]isize, // UResourceBundle* in/out
    status: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;
proc ures_getByKey(
    resourceBundle: ptr int,  # UResourceBundle*
    key: cstring,  # LPCSTR
    fillIn: ptr int,  # UResourceBundle* in/out
    status: ptr int32  # UErrorCode* in/out
): ptr int {.importc: "ures_getByKey", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
ptrdiff_t* ures_getByKey(
    ptrdiff_t* resourceBundle,   // UResourceBundle*
    const(char)* key,   // LPCSTR
    ptrdiff_t* fillIn,   // UResourceBundle* in/out
    int* status   // UErrorCode* in/out
);
ccall((:ures_getByKey, "icuuc.dll"), Ptr{Int},
      (Ptr{Int}, Cstring, Ptr{Int}, Ptr{Int32}),
      resourceBundle, key, fillIn, status)
# resourceBundle : UResourceBundle* -> Ptr{Int}
# key : LPCSTR -> Cstring
# fillIn : UResourceBundle* in/out -> Ptr{Int}
# status : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
intptr_t* ures_getByKey(
    intptr_t* resourceBundle,
    const char* key,
    intptr_t* fillIn,
    int32_t* status);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ures_getByKey(resourceBundle, key, fillIn, status)
-- resourceBundle : UResourceBundle*
-- key : LPCSTR
-- fillIn : UResourceBundle* in/out
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ures_getByKey = lib.func('__cdecl', 'ures_getByKey', 'intptr_t *', ['intptr_t *', 'str', 'intptr_t *', 'int32_t *']);
// ures_getByKey(resourceBundle, key, fillIn, status)
// resourceBundle : UResourceBundle* -> 'intptr_t *'
// key : LPCSTR -> 'str'
// fillIn : UResourceBundle* in/out -> 'intptr_t *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  ures_getByKey: { parameters: ["pointer", "buffer", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.ures_getByKey(resourceBundle, key, fillIn, status)
// resourceBundle : UResourceBundle* -> "pointer"
// key : LPCSTR -> "buffer"
// fillIn : UResourceBundle* in/out -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
intptr_t* ures_getByKey(
    intptr_t* resourceBundle,
    const char* key,
    intptr_t* fillIn,
    int32_t* status);
C, "icuuc.dll");
// $ffi->ures_getByKey(resourceBundle, key, fillIn, status);
// resourceBundle : UResourceBundle*
// key : LPCSTR
// fillIn : UResourceBundle* in/out
// status : 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);
    Pointer ures_getByKey(
        LongByReference resourceBundle,   // UResourceBundle*
        String key,   // LPCSTR
        LongByReference fillIn,   // UResourceBundle* in/out
        IntByReference status   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun ures_getByKey = ures_getByKey(
    resourceBundle : LibC::SSizeT*,   # UResourceBundle*
    key : UInt8*,   # LPCSTR
    fillIn : LibC::SSizeT*,   # UResourceBundle* in/out
    status : Int32*   # UErrorCode* in/out
  ) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ures_getByKeyNative = Pointer<IntPtr> Function(Pointer<IntPtr>, Pointer<Utf8>, Pointer<IntPtr>, Pointer<Int32>);
typedef ures_getByKeyDart = Pointer<IntPtr> Function(Pointer<IntPtr>, Pointer<Utf8>, Pointer<IntPtr>, Pointer<Int32>);
final ures_getByKey = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<ures_getByKeyNative, ures_getByKeyDart>('ures_getByKey');
// resourceBundle : UResourceBundle* -> Pointer<IntPtr>
// key : LPCSTR -> Pointer<Utf8>
// fillIn : UResourceBundle* in/out -> Pointer<IntPtr>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ures_getByKey(
  resourceBundle: Pointer;   // UResourceBundle*
  key: PAnsiChar;   // LPCSTR
  fillIn: Pointer;   // UResourceBundle* in/out
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'ures_getByKey';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ures_getByKey"
  c_ures_getByKey :: Ptr CIntPtr -> CString -> Ptr CIntPtr -> Ptr Int32 -> IO (Ptr CIntPtr)
-- resourceBundle : UResourceBundle* -> Ptr CIntPtr
-- key : LPCSTR -> CString
-- fillIn : UResourceBundle* in/out -> Ptr CIntPtr
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ures_getbykey =
  foreign "ures_getByKey"
    ((ptr intptr_t) @-> string @-> (ptr intptr_t) @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* resourceBundle : UResourceBundle* -> (ptr intptr_t) *)
(* key : LPCSTR -> string *)
(* fillIn : UResourceBundle* in/out -> (ptr intptr_t) *)
(* status : 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 ("ures_getByKey" ures-get-by-key :convention :cdecl) :pointer
  (resource-bundle :pointer)   ; UResourceBundle*
  (key :string)   ; LPCSTR
  (fill-in :pointer)   ; UResourceBundle* in/out
  (status :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ures_getByKey = Win32::API::More->new('icuuc',
    'LPVOID ures_getByKey(LPVOID resourceBundle, LPCSTR key, LPVOID fillIn, LPVOID status)');
# my $ret = $ures_getByKey->Call($resourceBundle, $key, $fillIn, $status);
# resourceBundle : UResourceBundle* -> LPVOID
# key : LPCSTR -> LPCSTR
# fillIn : UResourceBundle* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型