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
statusUErrorCode*inout

戻り値の型: 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 resourceBundle, key, fillIn, 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" int, str, int, int
; res = ures_getByKey(resourceBundle, key, fillIn, status)
; resourceBundle : UResourceBundle* -> "int"
; key : LPCSTR -> "str"
; fillIn : UResourceBundle* in/out -> "int"
; status : UErrorCode* in/out -> "int"
; UResourceBundle* ures_getByKey(UResourceBundle* resourceBundle, LPCSTR key, UResourceBundle* fillIn, UErrorCode* status)
#uselib "icuuc.dll"
#cfunc global ures_getByKey "ures_getByKey" int, str, int, int
; res = ures_getByKey(resourceBundle, key, fillIn, status)
; resourceBundle : UResourceBundle* -> "int"
; key : LPCSTR -> "str"
; fillIn : UResourceBundle* in/out -> "int"
; status : UErrorCode* in/out -> "int"
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`,…) を使用。