RegLoadMUIStringW
関数シグネチャ
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR RegLoadMUIStringW(
HKEY hKey,
LPCWSTR pszValue, // optional
LPWSTR pszOutBuf, // optional
DWORD cbOutBuf,
DWORD* pcbData, // optional
DWORD Flags,
LPCWSTR pszDirectory // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||
|---|---|---|---|---|---|---|---|
| hKey | HKEY | in | 開いているレジストリキーへのハンドル。キーは KEY_QUERY_VALUE アクセス権で開かれている必要があります。詳細については、 Registry Key Security and Access Rights を参照してください。 このハンドルは RegCreateKeyEx または RegOpenKeyEx 関数によって返されます。次の 定義済みキー のいずれかを指定することもできます: | ||||
| pszValue | LPCWSTR | inoptional | レジストリ値の名前。 | ||||
| pszOutBuf | LPWSTR | outoptional | 文字列を受け取るバッファーへのポインター。 次の形式の文字列は特別に処理されます: @[path]\dllname,-strID 識別子 strID を持つ文字列が dllname から読み込まれます。path は省略可能です。pszDirectory パラメーターが NULL でない場合、そのディレクトリがレジストリデータで指定されたパスの先頭に付加されます。なお、dllname には展開対象の環境変数を含めることができます。 | ||||
| cbOutBuf | DWORD | in | pszOutBuf バッファーのサイズ(バイト単位)。 | ||||
| pcbData | DWORD* | outoptional | pszOutBuf バッファーにコピーされたデータのサイズ(バイト単位)を受け取る変数へのポインター。 バッファーがデータを保持するのに十分な大きさでない場合、関数は ERROR_MORE_DATA を返し、必要なバッファーサイズを pcbData が指す変数に格納します。この場合、バッファーの内容は未定義です。 | ||||
| Flags | DWORD | in | このパラメーターには 0 または次の値を指定できます。
| ||||
| pszDirectory | LPCWSTR | inoptional | ディレクトリパス。 |
戻り値の型: WIN32_ERROR
公式ドキュメント
指定したキーおよびサブキーから、指定した文字列を読み込みます。(Unicode)
戻り値
関数が成功した場合、戻り値は ERROR_SUCCESS です。
関数が失敗した場合、戻り値は システムエラーコード です。
pcbData バッファーが文字列を受け取るには小さすぎる場合、関数は ERROR_MORE_DATA を返します。
この関数の ANSI バージョンは ERROR_CALL_NOT_IMPLEMENTED を返します。
解説(Remarks)
RegLoadMUIString 関数は Unicode でのみサポートされています。この関数には Unicode (W) 版と ANSI (A) 版の両方が宣言されていますが、RegLoadMUIStringA 関数は ERROR_CALL_NOT_IMPLEMENTED を返します。アプリケーションは RegLoadMUIStringW を明示的に呼び出すか、プラットフォーム呼び出し (PInvoke) で文字セットとして Unicode を指定する必要があります。
この関数を使用するアプリケーションをコンパイルするには、_WIN32_WINNT を 0x0600 以降として定義してください。詳細については、 Using the Windows Headers を参照してください。
winreg.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして RegLoadMUIString を定義しています。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じ、コンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR RegLoadMUIStringW(
HKEY hKey,
LPCWSTR pszValue, // optional
LPWSTR pszOutBuf, // optional
DWORD cbOutBuf,
DWORD* pcbData, // optional
DWORD Flags,
LPCWSTR pszDirectory // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint RegLoadMUIStringW(
IntPtr hKey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string pszValue, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszOutBuf, // LPWSTR optional, out
uint cbOutBuf, // DWORD
IntPtr pcbData, // DWORD* optional, out
uint Flags, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pszDirectory // LPCWSTR optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RegLoadMUIStringW(
hKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> pszValue As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pszOutBuf As System.Text.StringBuilder, ' LPWSTR optional, out
cbOutBuf As UInteger, ' DWORD
pcbData As IntPtr, ' DWORD* optional, out
Flags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pszDirectory As String ' LPCWSTR optional
) As UInteger
End Function' hKey : HKEY
' pszValue : LPCWSTR optional
' pszOutBuf : LPWSTR optional, out
' cbOutBuf : DWORD
' pcbData : DWORD* optional, out
' Flags : DWORD
' pszDirectory : LPCWSTR optional
Declare PtrSafe Function RegLoadMUIStringW Lib "advapi32" ( _
ByVal hKey As LongPtr, _
ByVal pszValue As LongPtr, _
ByVal pszOutBuf As LongPtr, _
ByVal cbOutBuf As Long, _
ByVal pcbData As LongPtr, _
ByVal Flags As Long, _
ByVal pszDirectory As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegLoadMUIStringW = ctypes.windll.advapi32.RegLoadMUIStringW
RegLoadMUIStringW.restype = wintypes.DWORD
RegLoadMUIStringW.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.LPCWSTR, # pszValue : LPCWSTR optional
wintypes.LPWSTR, # pszOutBuf : LPWSTR optional, out
wintypes.DWORD, # cbOutBuf : DWORD
ctypes.POINTER(wintypes.DWORD), # pcbData : DWORD* optional, out
wintypes.DWORD, # Flags : DWORD
wintypes.LPCWSTR, # pszDirectory : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
RegLoadMUIStringW = Fiddle::Function.new(
lib['RegLoadMUIStringW'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
Fiddle::TYPE_VOIDP, # pszValue : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pszOutBuf : LPWSTR optional, out
-Fiddle::TYPE_INT, # cbOutBuf : DWORD
Fiddle::TYPE_VOIDP, # pcbData : DWORD* optional, out
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # pszDirectory : LPCWSTR optional
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advapi32")]
extern "system" {
fn RegLoadMUIStringW(
hKey: *mut core::ffi::c_void, // HKEY
pszValue: *const u16, // LPCWSTR optional
pszOutBuf: *mut u16, // LPWSTR optional, out
cbOutBuf: u32, // DWORD
pcbData: *mut u32, // DWORD* optional, out
Flags: u32, // DWORD
pszDirectory: *const u16 // LPCWSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode)]
public static extern uint RegLoadMUIStringW(IntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string pszValue, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszOutBuf, uint cbOutBuf, IntPtr pcbData, uint Flags, [MarshalAs(UnmanagedType.LPWStr)] string pszDirectory);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegLoadMUIStringW' -Namespace Win32 -PassThru
# $api::RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)#uselib "ADVAPI32.dll"
#func global RegLoadMUIStringW "RegLoadMUIStringW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; RegLoadMUIStringW hKey, pszValue, varptr(pszOutBuf), cbOutBuf, varptr(pcbData), Flags, pszDirectory ; 戻り値は stat
; hKey : HKEY -> "wptr"
; pszValue : LPCWSTR optional -> "wptr"
; pszOutBuf : LPWSTR optional, out -> "wptr"
; cbOutBuf : DWORD -> "wptr"
; pcbData : DWORD* optional, out -> "wptr"
; Flags : DWORD -> "wptr"
; pszDirectory : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringW "RegLoadMUIStringW" sptr, wstr, var, int, var, int, wstr ; res = RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory) ; hKey : HKEY -> "sptr" ; pszValue : LPCWSTR optional -> "wstr" ; pszOutBuf : LPWSTR optional, out -> "var" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "var" ; Flags : DWORD -> "int" ; pszDirectory : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringW "RegLoadMUIStringW" sptr, wstr, sptr, int, sptr, int, wstr ; res = RegLoadMUIStringW(hKey, pszValue, varptr(pszOutBuf), cbOutBuf, varptr(pcbData), Flags, pszDirectory) ; hKey : HKEY -> "sptr" ; pszValue : LPCWSTR optional -> "wstr" ; pszOutBuf : LPWSTR optional, out -> "sptr" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "sptr" ; Flags : DWORD -> "int" ; pszDirectory : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; WIN32_ERROR RegLoadMUIStringW(HKEY hKey, LPCWSTR pszValue, LPWSTR pszOutBuf, DWORD cbOutBuf, DWORD* pcbData, DWORD Flags, LPCWSTR pszDirectory) #uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringW "RegLoadMUIStringW" intptr, wstr, var, int, var, int, wstr ; res = RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory) ; hKey : HKEY -> "intptr" ; pszValue : LPCWSTR optional -> "wstr" ; pszOutBuf : LPWSTR optional, out -> "var" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "var" ; Flags : DWORD -> "int" ; pszDirectory : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR RegLoadMUIStringW(HKEY hKey, LPCWSTR pszValue, LPWSTR pszOutBuf, DWORD cbOutBuf, DWORD* pcbData, DWORD Flags, LPCWSTR pszDirectory) #uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringW "RegLoadMUIStringW" intptr, wstr, intptr, int, intptr, int, wstr ; res = RegLoadMUIStringW(hKey, pszValue, varptr(pszOutBuf), cbOutBuf, varptr(pcbData), Flags, pszDirectory) ; hKey : HKEY -> "intptr" ; pszValue : LPCWSTR optional -> "wstr" ; pszOutBuf : LPWSTR optional, out -> "intptr" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "intptr" ; Flags : DWORD -> "int" ; pszDirectory : LPCWSTR optional -> "wstr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procRegLoadMUIStringW = advapi32.NewProc("RegLoadMUIStringW")
)
// hKey (HKEY), pszValue (LPCWSTR optional), pszOutBuf (LPWSTR optional, out), cbOutBuf (DWORD), pcbData (DWORD* optional, out), Flags (DWORD), pszDirectory (LPCWSTR optional)
r1, _, err := procRegLoadMUIStringW.Call(
uintptr(hKey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszValue))),
uintptr(pszOutBuf),
uintptr(cbOutBuf),
uintptr(pcbData),
uintptr(Flags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDirectory))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction RegLoadMUIStringW(
hKey: THandle; // HKEY
pszValue: PWideChar; // LPCWSTR optional
pszOutBuf: PWideChar; // LPWSTR optional, out
cbOutBuf: DWORD; // DWORD
pcbData: Pointer; // DWORD* optional, out
Flags: DWORD; // DWORD
pszDirectory: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'RegLoadMUIStringW';result := DllCall("ADVAPI32\RegLoadMUIStringW"
, "Ptr", hKey ; HKEY
, "WStr", pszValue ; LPCWSTR optional
, "Ptr", pszOutBuf ; LPWSTR optional, out
, "UInt", cbOutBuf ; DWORD
, "Ptr", pcbData ; DWORD* optional, out
, "UInt", Flags ; DWORD
, "WStr", pszDirectory ; LPCWSTR optional
, "UInt") ; return: WIN32_ERROR●RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory) = DLL("ADVAPI32.dll", "dword RegLoadMUIStringW(void*, char*, char*, dword, void*, dword, char*)")
# 呼び出し: RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
# hKey : HKEY -> "void*"
# pszValue : LPCWSTR optional -> "char*"
# pszOutBuf : LPWSTR optional, out -> "char*"
# cbOutBuf : DWORD -> "dword"
# pcbData : DWORD* optional, out -> "void*"
# Flags : DWORD -> "dword"
# pszDirectory : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "advapi32" fn RegLoadMUIStringW(
hKey: ?*anyopaque, // HKEY
pszValue: [*c]const u16, // LPCWSTR optional
pszOutBuf: [*c]u16, // LPWSTR optional, out
cbOutBuf: u32, // DWORD
pcbData: [*c]u32, // DWORD* optional, out
Flags: u32, // DWORD
pszDirectory: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc RegLoadMUIStringW(
hKey: pointer, # HKEY
pszValue: WideCString, # LPCWSTR optional
pszOutBuf: ptr uint16, # LPWSTR optional, out
cbOutBuf: uint32, # DWORD
pcbData: ptr uint32, # DWORD* optional, out
Flags: uint32, # DWORD
pszDirectory: WideCString # LPCWSTR optional
): uint32 {.importc: "RegLoadMUIStringW", stdcall, dynlib: "ADVAPI32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "advapi32");
extern(Windows)
uint RegLoadMUIStringW(
void* hKey, // HKEY
const(wchar)* pszValue, // LPCWSTR optional
wchar* pszOutBuf, // LPWSTR optional, out
uint cbOutBuf, // DWORD
uint* pcbData, // DWORD* optional, out
uint Flags, // DWORD
const(wchar)* pszDirectory // LPCWSTR optional
);ccall((:RegLoadMUIStringW, "ADVAPI32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, Ptr{UInt16}, UInt32, Ptr{UInt32}, UInt32, Cwstring),
hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
# hKey : HKEY -> Ptr{Cvoid}
# pszValue : LPCWSTR optional -> Cwstring
# pszOutBuf : LPWSTR optional, out -> Ptr{UInt16}
# cbOutBuf : DWORD -> UInt32
# pcbData : DWORD* optional, out -> Ptr{UInt32}
# Flags : DWORD -> UInt32
# pszDirectory : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t RegLoadMUIStringW(
void* hKey,
const uint16_t* pszValue,
uint16_t* pszOutBuf,
uint32_t cbOutBuf,
uint32_t* pcbData,
uint32_t Flags,
const uint16_t* pszDirectory);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
-- hKey : HKEY
-- pszValue : LPCWSTR optional
-- pszOutBuf : LPWSTR optional, out
-- cbOutBuf : DWORD
-- pcbData : DWORD* optional, out
-- Flags : DWORD
-- pszDirectory : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const RegLoadMUIStringW = lib.func('__stdcall', 'RegLoadMUIStringW', 'uint32_t', ['void *', 'str16', 'uint16_t *', 'uint32_t', 'uint32_t *', 'uint32_t', 'str16']);
// RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
// hKey : HKEY -> 'void *'
// pszValue : LPCWSTR optional -> 'str16'
// pszOutBuf : LPWSTR optional, out -> 'uint16_t *'
// cbOutBuf : DWORD -> 'uint32_t'
// pcbData : DWORD* optional, out -> 'uint32_t *'
// Flags : DWORD -> 'uint32_t'
// pszDirectory : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
RegLoadMUIStringW: { parameters: ["pointer", "buffer", "buffer", "u32", "pointer", "u32", "buffer"], result: "u32" },
});
// lib.symbols.RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
// hKey : HKEY -> "pointer"
// pszValue : LPCWSTR optional -> "buffer"
// pszOutBuf : LPWSTR optional, out -> "buffer"
// cbOutBuf : DWORD -> "u32"
// pcbData : DWORD* optional, out -> "pointer"
// Flags : DWORD -> "u32"
// pszDirectory : LPCWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RegLoadMUIStringW(
void* hKey,
const uint16_t* pszValue,
uint16_t* pszOutBuf,
uint32_t cbOutBuf,
uint32_t* pcbData,
uint32_t Flags,
const uint16_t* pszDirectory);
C, "ADVAPI32.dll");
// $ffi->RegLoadMUIStringW(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory);
// hKey : HKEY
// pszValue : LPCWSTR optional
// pszOutBuf : LPWSTR optional, out
// cbOutBuf : DWORD
// pcbData : DWORD* optional, out
// Flags : DWORD
// pszDirectory : LPCWSTR optional
// 構造体/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 Advapi32 extends StdCallLibrary {
Advapi32 INSTANCE = Native.load("advapi32", Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
int RegLoadMUIStringW(
Pointer hKey, // HKEY
WString pszValue, // LPCWSTR optional
char[] pszOutBuf, // LPWSTR optional, out
int cbOutBuf, // DWORD
IntByReference pcbData, // DWORD* optional, out
int Flags, // DWORD
WString pszDirectory // LPCWSTR optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("advapi32")]
lib LibADVAPI32
fun RegLoadMUIStringW = RegLoadMUIStringW(
hKey : Void*, # HKEY
pszValue : UInt16*, # LPCWSTR optional
pszOutBuf : UInt16*, # LPWSTR optional, out
cbOutBuf : UInt32, # DWORD
pcbData : UInt32*, # DWORD* optional, out
Flags : UInt32, # DWORD
pszDirectory : UInt16* # LPCWSTR optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RegLoadMUIStringWNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Uint32>, Uint32, Pointer<Utf16>);
typedef RegLoadMUIStringWDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Uint32>, int, Pointer<Utf16>);
final RegLoadMUIStringW = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<RegLoadMUIStringWNative, RegLoadMUIStringWDart>('RegLoadMUIStringW');
// hKey : HKEY -> Pointer<Void>
// pszValue : LPCWSTR optional -> Pointer<Utf16>
// pszOutBuf : LPWSTR optional, out -> Pointer<Utf16>
// cbOutBuf : DWORD -> Uint32
// pcbData : DWORD* optional, out -> Pointer<Uint32>
// Flags : DWORD -> Uint32
// pszDirectory : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RegLoadMUIStringW(
hKey: THandle; // HKEY
pszValue: PWideChar; // LPCWSTR optional
pszOutBuf: PWideChar; // LPWSTR optional, out
cbOutBuf: DWORD; // DWORD
pcbData: Pointer; // DWORD* optional, out
Flags: DWORD; // DWORD
pszDirectory: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'RegLoadMUIStringW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RegLoadMUIStringW"
c_RegLoadMUIStringW :: Ptr () -> CWString -> CWString -> Word32 -> Ptr Word32 -> Word32 -> CWString -> IO Word32
-- hKey : HKEY -> Ptr ()
-- pszValue : LPCWSTR optional -> CWString
-- pszOutBuf : LPWSTR optional, out -> CWString
-- cbOutBuf : DWORD -> Word32
-- pcbData : DWORD* optional, out -> Ptr Word32
-- Flags : DWORD -> Word32
-- pszDirectory : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let regloadmuistringw =
foreign "RegLoadMUIStringW"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> uint32_t @-> (ptr uint16_t) @-> returning uint32_t)
(* hKey : HKEY -> (ptr void) *)
(* pszValue : LPCWSTR optional -> (ptr uint16_t) *)
(* pszOutBuf : LPWSTR optional, out -> (ptr uint16_t) *)
(* cbOutBuf : DWORD -> uint32_t *)
(* pcbData : DWORD* optional, out -> (ptr uint32_t) *)
(* Flags : DWORD -> uint32_t *)
(* pszDirectory : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("RegLoadMUIStringW" reg-load-muistring-w :convention :stdcall) :uint32
(h-key :pointer) ; HKEY
(psz-value (:string :encoding :utf-16le)) ; LPCWSTR optional
(psz-out-buf :pointer) ; LPWSTR optional, out
(cb-out-buf :uint32) ; DWORD
(pcb-data :pointer) ; DWORD* optional, out
(flags :uint32) ; DWORD
(psz-directory (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RegLoadMUIStringW = Win32::API::More->new('ADVAPI32',
'DWORD RegLoadMUIStringW(HANDLE hKey, LPCWSTR pszValue, LPWSTR pszOutBuf, DWORD cbOutBuf, LPVOID pcbData, DWORD Flags, LPCWSTR pszDirectory)');
# my $ret = $RegLoadMUIStringW->Call($hKey, $pszValue, $pszOutBuf, $cbOutBuf, $pcbData, $Flags, $pszDirectory);
# hKey : HKEY -> HANDLE
# pszValue : LPCWSTR optional -> LPCWSTR
# pszOutBuf : LPWSTR optional, out -> LPWSTR
# cbOutBuf : DWORD -> DWORD
# pcbData : DWORD* optional, out -> LPVOID
# Flags : DWORD -> DWORD
# pszDirectory : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f RegLoadMUIStringA (ANSI版) — レジストリ値からローカライズされた文字列を読み込む。