ホーム › System.ClrHosting › LoadStringRCEx
LoadStringRCEx
関数ロケールを指定してリソースIDから文字列リソースを読み込む。
シグネチャ
// MSCorEE.dll
#include <windows.h>
HRESULT LoadStringRCEx(
DWORD lcid,
DWORD iResouceID,
LPWSTR szBuffer,
INT iMax,
INT bQuiet,
INT* pcwchUsed
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lcid | DWORD | in |
| iResouceID | DWORD | in |
| szBuffer | LPWSTR | out |
| iMax | INT | in |
| bQuiet | INT | in |
| pcwchUsed | INT* | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// MSCorEE.dll
#include <windows.h>
HRESULT LoadStringRCEx(
DWORD lcid,
DWORD iResouceID,
LPWSTR szBuffer,
INT iMax,
INT bQuiet,
INT* pcwchUsed
);[DllImport("MSCorEE.dll", ExactSpelling = true)]
static extern int LoadStringRCEx(
uint lcid, // DWORD
uint iResouceID, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szBuffer, // LPWSTR out
int iMax, // INT
int bQuiet, // INT
ref int pcwchUsed // INT* in/out
);<DllImport("MSCorEE.dll", ExactSpelling:=True)>
Public Shared Function LoadStringRCEx(
lcid As UInteger, ' DWORD
iResouceID As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> szBuffer As System.Text.StringBuilder, ' LPWSTR out
iMax As Integer, ' INT
bQuiet As Integer, ' INT
ByRef pcwchUsed As Integer ' INT* in/out
) As Integer
End Function' lcid : DWORD
' iResouceID : DWORD
' szBuffer : LPWSTR out
' iMax : INT
' bQuiet : INT
' pcwchUsed : INT* in/out
Declare PtrSafe Function LoadStringRCEx Lib "mscoree" ( _
ByVal lcid As Long, _
ByVal iResouceID As Long, _
ByVal szBuffer As LongPtr, _
ByVal iMax As Long, _
ByVal bQuiet As Long, _
ByRef pcwchUsed As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LoadStringRCEx = ctypes.windll.mscoree.LoadStringRCEx
LoadStringRCEx.restype = ctypes.c_int
LoadStringRCEx.argtypes = [
wintypes.DWORD, # lcid : DWORD
wintypes.DWORD, # iResouceID : DWORD
wintypes.LPWSTR, # szBuffer : LPWSTR out
ctypes.c_int, # iMax : INT
ctypes.c_int, # bQuiet : INT
ctypes.POINTER(ctypes.c_int), # pcwchUsed : INT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSCorEE.dll')
LoadStringRCEx = Fiddle::Function.new(
lib['LoadStringRCEx'],
[
-Fiddle::TYPE_INT, # lcid : DWORD
-Fiddle::TYPE_INT, # iResouceID : DWORD
Fiddle::TYPE_VOIDP, # szBuffer : LPWSTR out
Fiddle::TYPE_INT, # iMax : INT
Fiddle::TYPE_INT, # bQuiet : INT
Fiddle::TYPE_VOIDP, # pcwchUsed : INT* in/out
],
Fiddle::TYPE_INT)#[link(name = "mscoree")]
extern "system" {
fn LoadStringRCEx(
lcid: u32, // DWORD
iResouceID: u32, // DWORD
szBuffer: *mut u16, // LPWSTR out
iMax: i32, // INT
bQuiet: i32, // INT
pcwchUsed: *mut i32 // INT* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSCorEE.dll")]
public static extern int LoadStringRCEx(uint lcid, uint iResouceID, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szBuffer, int iMax, int bQuiet, ref int pcwchUsed);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSCorEE_LoadStringRCEx' -Namespace Win32 -PassThru
# $api::LoadStringRCEx(lcid, iResouceID, szBuffer, iMax, bQuiet, pcwchUsed)#uselib "MSCorEE.dll"
#func global LoadStringRCEx "LoadStringRCEx" sptr, sptr, sptr, sptr, sptr, sptr
; LoadStringRCEx lcid, iResouceID, varptr(szBuffer), iMax, bQuiet, varptr(pcwchUsed) ; 戻り値は stat
; lcid : DWORD -> "sptr"
; iResouceID : DWORD -> "sptr"
; szBuffer : LPWSTR out -> "sptr"
; iMax : INT -> "sptr"
; bQuiet : INT -> "sptr"
; pcwchUsed : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MSCorEE.dll" #cfunc global LoadStringRCEx "LoadStringRCEx" int, int, var, int, int, var ; res = LoadStringRCEx(lcid, iResouceID, szBuffer, iMax, bQuiet, pcwchUsed) ; lcid : DWORD -> "int" ; iResouceID : DWORD -> "int" ; szBuffer : LPWSTR out -> "var" ; iMax : INT -> "int" ; bQuiet : INT -> "int" ; pcwchUsed : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MSCorEE.dll" #cfunc global LoadStringRCEx "LoadStringRCEx" int, int, sptr, int, int, sptr ; res = LoadStringRCEx(lcid, iResouceID, varptr(szBuffer), iMax, bQuiet, varptr(pcwchUsed)) ; lcid : DWORD -> "int" ; iResouceID : DWORD -> "int" ; szBuffer : LPWSTR out -> "sptr" ; iMax : INT -> "int" ; bQuiet : INT -> "int" ; pcwchUsed : INT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT LoadStringRCEx(DWORD lcid, DWORD iResouceID, LPWSTR szBuffer, INT iMax, INT bQuiet, INT* pcwchUsed) #uselib "MSCorEE.dll" #cfunc global LoadStringRCEx "LoadStringRCEx" int, int, var, int, int, var ; res = LoadStringRCEx(lcid, iResouceID, szBuffer, iMax, bQuiet, pcwchUsed) ; lcid : DWORD -> "int" ; iResouceID : DWORD -> "int" ; szBuffer : LPWSTR out -> "var" ; iMax : INT -> "int" ; bQuiet : INT -> "int" ; pcwchUsed : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT LoadStringRCEx(DWORD lcid, DWORD iResouceID, LPWSTR szBuffer, INT iMax, INT bQuiet, INT* pcwchUsed) #uselib "MSCorEE.dll" #cfunc global LoadStringRCEx "LoadStringRCEx" int, int, intptr, int, int, intptr ; res = LoadStringRCEx(lcid, iResouceID, varptr(szBuffer), iMax, bQuiet, varptr(pcwchUsed)) ; lcid : DWORD -> "int" ; iResouceID : DWORD -> "int" ; szBuffer : LPWSTR out -> "intptr" ; iMax : INT -> "int" ; bQuiet : INT -> "int" ; pcwchUsed : INT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscoree = windows.NewLazySystemDLL("MSCorEE.dll")
procLoadStringRCEx = mscoree.NewProc("LoadStringRCEx")
)
// lcid (DWORD), iResouceID (DWORD), szBuffer (LPWSTR out), iMax (INT), bQuiet (INT), pcwchUsed (INT* in/out)
r1, _, err := procLoadStringRCEx.Call(
uintptr(lcid),
uintptr(iResouceID),
uintptr(szBuffer),
uintptr(iMax),
uintptr(bQuiet),
uintptr(pcwchUsed),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction LoadStringRCEx(
lcid: DWORD; // DWORD
iResouceID: DWORD; // DWORD
szBuffer: PWideChar; // LPWSTR out
iMax: Integer; // INT
bQuiet: Integer; // INT
pcwchUsed: Pointer // INT* in/out
): Integer; stdcall;
external 'MSCorEE.dll' name 'LoadStringRCEx';result := DllCall("MSCorEE\LoadStringRCEx"
, "UInt", lcid ; DWORD
, "UInt", iResouceID ; DWORD
, "Ptr", szBuffer ; LPWSTR out
, "Int", iMax ; INT
, "Int", bQuiet ; INT
, "Ptr", pcwchUsed ; INT* in/out
, "Int") ; return: HRESULT●LoadStringRCEx(lcid, iResouceID, szBuffer, iMax, bQuiet, pcwchUsed) = DLL("MSCorEE.dll", "int LoadStringRCEx(dword, dword, char*, int, int, void*)")
# 呼び出し: LoadStringRCEx(lcid, iResouceID, szBuffer, iMax, bQuiet, pcwchUsed)
# lcid : DWORD -> "dword"
# iResouceID : DWORD -> "dword"
# szBuffer : LPWSTR out -> "char*"
# iMax : INT -> "int"
# bQuiet : INT -> "int"
# pcwchUsed : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。