RegLoadMUIStringA
関数シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR RegLoadMUIStringA(
HKEY hKey,
LPCSTR pszValue, // optional
LPSTR pszOutBuf, // optional
DWORD cbOutBuf,
DWORD* pcbData, // optional
DWORD Flags,
LPCSTR pszDirectory // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||
|---|---|---|---|---|---|---|---|
| hKey | HKEY | in | 開いているレジストリ キーへのハンドル。キーは KEY_QUERY_VALUE アクセス権で開かれている必要があります。詳細については、 レジストリ キーのセキュリティとアクセス権を参照してください。 このハンドルは RegCreateKeyEx または RegOpenKeyEx 関数によって返されます。また、次の 定義済みキーのいずれかを指定することもできます: | ||||
| pszValue | LPCSTR | inoptional | レジストリ値の名前。 | ||||
| pszOutBuf | LPSTR | 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 | LPCSTR | inoptional | ディレクトリ パス。 |
戻り値の型: WIN32_ERROR
公式ドキュメント
指定したキーおよびサブキーから指定した文字列を読み込みます。(ANSI)
戻り値
関数が成功した場合、戻り値は 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 以降として定義してください。詳細については、 Windows ヘッダーの使用を参照してください。
winreg.h ヘッダーは、RegLoadMUIString を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じてコンパイル エラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR RegLoadMUIStringA(
HKEY hKey,
LPCSTR pszValue, // optional
LPSTR pszOutBuf, // optional
DWORD cbOutBuf,
DWORD* pcbData, // optional
DWORD Flags,
LPCSTR pszDirectory // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint RegLoadMUIStringA(
IntPtr hKey, // HKEY
[MarshalAs(UnmanagedType.LPStr)] string pszValue, // LPCSTR optional
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszOutBuf, // LPSTR optional, out
uint cbOutBuf, // DWORD
IntPtr pcbData, // DWORD* optional, out
uint Flags, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string pszDirectory // LPCSTR optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RegLoadMUIStringA(
hKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPStr)> pszValue As String, ' LPCSTR optional
<MarshalAs(UnmanagedType.LPStr)> pszOutBuf As System.Text.StringBuilder, ' LPSTR optional, out
cbOutBuf As UInteger, ' DWORD
pcbData As IntPtr, ' DWORD* optional, out
Flags As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszDirectory As String ' LPCSTR optional
) As UInteger
End Function' hKey : HKEY
' pszValue : LPCSTR optional
' pszOutBuf : LPSTR optional, out
' cbOutBuf : DWORD
' pcbData : DWORD* optional, out
' Flags : DWORD
' pszDirectory : LPCSTR optional
Declare PtrSafe Function RegLoadMUIStringA Lib "advapi32" ( _
ByVal hKey As LongPtr, _
ByVal pszValue As String, _
ByVal pszOutBuf As String, _
ByVal cbOutBuf As Long, _
ByVal pcbData As LongPtr, _
ByVal Flags As Long, _
ByVal pszDirectory As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegLoadMUIStringA = ctypes.windll.advapi32.RegLoadMUIStringA
RegLoadMUIStringA.restype = wintypes.DWORD
RegLoadMUIStringA.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.LPCSTR, # pszValue : LPCSTR optional
wintypes.LPSTR, # pszOutBuf : LPSTR optional, out
wintypes.DWORD, # cbOutBuf : DWORD
ctypes.POINTER(wintypes.DWORD), # pcbData : DWORD* optional, out
wintypes.DWORD, # Flags : DWORD
wintypes.LPCSTR, # pszDirectory : LPCSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
RegLoadMUIStringA = Fiddle::Function.new(
lib['RegLoadMUIStringA'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
Fiddle::TYPE_VOIDP, # pszValue : LPCSTR optional
Fiddle::TYPE_VOIDP, # pszOutBuf : LPSTR optional, out
-Fiddle::TYPE_INT, # cbOutBuf : DWORD
Fiddle::TYPE_VOIDP, # pcbData : DWORD* optional, out
-Fiddle::TYPE_INT, # Flags : DWORD
Fiddle::TYPE_VOIDP, # pszDirectory : LPCSTR optional
],
-Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn RegLoadMUIStringA(
hKey: *mut core::ffi::c_void, // HKEY
pszValue: *const u8, // LPCSTR optional
pszOutBuf: *mut u8, // LPSTR optional, out
cbOutBuf: u32, // DWORD
pcbData: *mut u32, // DWORD* optional, out
Flags: u32, // DWORD
pszDirectory: *const u8 // LPCSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi)]
public static extern uint RegLoadMUIStringA(IntPtr hKey, [MarshalAs(UnmanagedType.LPStr)] string pszValue, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszOutBuf, uint cbOutBuf, IntPtr pcbData, uint Flags, [MarshalAs(UnmanagedType.LPStr)] string pszDirectory);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegLoadMUIStringA' -Namespace Win32 -PassThru
# $api::RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)#uselib "ADVAPI32.dll"
#func global RegLoadMUIStringA "RegLoadMUIStringA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; RegLoadMUIStringA hKey, pszValue, varptr(pszOutBuf), cbOutBuf, varptr(pcbData), Flags, pszDirectory ; 戻り値は stat
; hKey : HKEY -> "sptr"
; pszValue : LPCSTR optional -> "sptr"
; pszOutBuf : LPSTR optional, out -> "sptr"
; cbOutBuf : DWORD -> "sptr"
; pcbData : DWORD* optional, out -> "sptr"
; Flags : DWORD -> "sptr"
; pszDirectory : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringA "RegLoadMUIStringA" sptr, str, var, int, var, int, str ; res = RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory) ; hKey : HKEY -> "sptr" ; pszValue : LPCSTR optional -> "str" ; pszOutBuf : LPSTR optional, out -> "var" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "var" ; Flags : DWORD -> "int" ; pszDirectory : LPCSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringA "RegLoadMUIStringA" sptr, str, sptr, int, sptr, int, str ; res = RegLoadMUIStringA(hKey, pszValue, varptr(pszOutBuf), cbOutBuf, varptr(pcbData), Flags, pszDirectory) ; hKey : HKEY -> "sptr" ; pszValue : LPCSTR optional -> "str" ; pszOutBuf : LPSTR optional, out -> "sptr" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "sptr" ; Flags : DWORD -> "int" ; pszDirectory : LPCSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; WIN32_ERROR RegLoadMUIStringA(HKEY hKey, LPCSTR pszValue, LPSTR pszOutBuf, DWORD cbOutBuf, DWORD* pcbData, DWORD Flags, LPCSTR pszDirectory) #uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringA "RegLoadMUIStringA" intptr, str, var, int, var, int, str ; res = RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory) ; hKey : HKEY -> "intptr" ; pszValue : LPCSTR optional -> "str" ; pszOutBuf : LPSTR optional, out -> "var" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "var" ; Flags : DWORD -> "int" ; pszDirectory : LPCSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR RegLoadMUIStringA(HKEY hKey, LPCSTR pszValue, LPSTR pszOutBuf, DWORD cbOutBuf, DWORD* pcbData, DWORD Flags, LPCSTR pszDirectory) #uselib "ADVAPI32.dll" #cfunc global RegLoadMUIStringA "RegLoadMUIStringA" intptr, str, intptr, int, intptr, int, str ; res = RegLoadMUIStringA(hKey, pszValue, varptr(pszOutBuf), cbOutBuf, varptr(pcbData), Flags, pszDirectory) ; hKey : HKEY -> "intptr" ; pszValue : LPCSTR optional -> "str" ; pszOutBuf : LPSTR optional, out -> "intptr" ; cbOutBuf : DWORD -> "int" ; pcbData : DWORD* optional, out -> "intptr" ; Flags : DWORD -> "int" ; pszDirectory : LPCSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procRegLoadMUIStringA = advapi32.NewProc("RegLoadMUIStringA")
)
// hKey (HKEY), pszValue (LPCSTR optional), pszOutBuf (LPSTR optional, out), cbOutBuf (DWORD), pcbData (DWORD* optional, out), Flags (DWORD), pszDirectory (LPCSTR optional)
r1, _, err := procRegLoadMUIStringA.Call(
uintptr(hKey),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszValue))),
uintptr(pszOutBuf),
uintptr(cbOutBuf),
uintptr(pcbData),
uintptr(Flags),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszDirectory))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction RegLoadMUIStringA(
hKey: THandle; // HKEY
pszValue: PAnsiChar; // LPCSTR optional
pszOutBuf: PAnsiChar; // LPSTR optional, out
cbOutBuf: DWORD; // DWORD
pcbData: Pointer; // DWORD* optional, out
Flags: DWORD; // DWORD
pszDirectory: PAnsiChar // LPCSTR optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'RegLoadMUIStringA';result := DllCall("ADVAPI32\RegLoadMUIStringA"
, "Ptr", hKey ; HKEY
, "AStr", pszValue ; LPCSTR optional
, "Ptr", pszOutBuf ; LPSTR optional, out
, "UInt", cbOutBuf ; DWORD
, "Ptr", pcbData ; DWORD* optional, out
, "UInt", Flags ; DWORD
, "AStr", pszDirectory ; LPCSTR optional
, "UInt") ; return: WIN32_ERROR●RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory) = DLL("ADVAPI32.dll", "dword RegLoadMUIStringA(void*, char*, char*, dword, void*, dword, char*)")
# 呼び出し: RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
# hKey : HKEY -> "void*"
# pszValue : LPCSTR optional -> "char*"
# pszOutBuf : LPSTR optional, out -> "char*"
# cbOutBuf : DWORD -> "dword"
# pcbData : DWORD* optional, out -> "void*"
# Flags : DWORD -> "dword"
# pszDirectory : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "advapi32" fn RegLoadMUIStringA(
hKey: ?*anyopaque, // HKEY
pszValue: [*c]const u8, // LPCSTR optional
pszOutBuf: [*c]u8, // LPSTR optional, out
cbOutBuf: u32, // DWORD
pcbData: [*c]u32, // DWORD* optional, out
Flags: u32, // DWORD
pszDirectory: [*c]const u8 // LPCSTR optional
) callconv(std.os.windows.WINAPI) u32;proc RegLoadMUIStringA(
hKey: pointer, # HKEY
pszValue: cstring, # LPCSTR optional
pszOutBuf: ptr char, # LPSTR optional, out
cbOutBuf: uint32, # DWORD
pcbData: ptr uint32, # DWORD* optional, out
Flags: uint32, # DWORD
pszDirectory: cstring # LPCSTR optional
): uint32 {.importc: "RegLoadMUIStringA", stdcall, dynlib: "ADVAPI32.dll".}pragma(lib, "advapi32");
extern(Windows)
uint RegLoadMUIStringA(
void* hKey, // HKEY
const(char)* pszValue, // LPCSTR optional
char* pszOutBuf, // LPSTR optional, out
uint cbOutBuf, // DWORD
uint* pcbData, // DWORD* optional, out
uint Flags, // DWORD
const(char)* pszDirectory // LPCSTR optional
);ccall((:RegLoadMUIStringA, "ADVAPI32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cstring, Ptr{UInt8}, UInt32, Ptr{UInt32}, UInt32, Cstring),
hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
# hKey : HKEY -> Ptr{Cvoid}
# pszValue : LPCSTR optional -> Cstring
# pszOutBuf : LPSTR optional, out -> Ptr{UInt8}
# cbOutBuf : DWORD -> UInt32
# pcbData : DWORD* optional, out -> Ptr{UInt32}
# Flags : DWORD -> UInt32
# pszDirectory : LPCSTR optional -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t RegLoadMUIStringA(
void* hKey,
const char* pszValue,
char* pszOutBuf,
uint32_t cbOutBuf,
uint32_t* pcbData,
uint32_t Flags,
const char* pszDirectory);
]]
local advapi32 = ffi.load("advapi32")
-- advapi32.RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
-- hKey : HKEY
-- pszValue : LPCSTR optional
-- pszOutBuf : LPSTR optional, out
-- cbOutBuf : DWORD
-- pcbData : DWORD* optional, out
-- Flags : DWORD
-- pszDirectory : LPCSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('ADVAPI32.dll');
const RegLoadMUIStringA = lib.func('__stdcall', 'RegLoadMUIStringA', 'uint32_t', ['void *', 'str', 'char *', 'uint32_t', 'uint32_t *', 'uint32_t', 'str']);
// RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
// hKey : HKEY -> 'void *'
// pszValue : LPCSTR optional -> 'str'
// pszOutBuf : LPSTR optional, out -> 'char *'
// cbOutBuf : DWORD -> 'uint32_t'
// pcbData : DWORD* optional, out -> 'uint32_t *'
// Flags : DWORD -> 'uint32_t'
// pszDirectory : LPCSTR optional -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVAPI32.dll", {
RegLoadMUIStringA: { parameters: ["pointer", "buffer", "buffer", "u32", "pointer", "u32", "buffer"], result: "u32" },
});
// lib.symbols.RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory)
// hKey : HKEY -> "pointer"
// pszValue : LPCSTR optional -> "buffer"
// pszOutBuf : LPSTR optional, out -> "buffer"
// cbOutBuf : DWORD -> "u32"
// pcbData : DWORD* optional, out -> "pointer"
// Flags : DWORD -> "u32"
// pszDirectory : LPCSTR optional -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t RegLoadMUIStringA(
void* hKey,
const char* pszValue,
char* pszOutBuf,
uint32_t cbOutBuf,
uint32_t* pcbData,
uint32_t Flags,
const char* pszDirectory);
C, "ADVAPI32.dll");
// $ffi->RegLoadMUIStringA(hKey, pszValue, pszOutBuf, cbOutBuf, pcbData, Flags, pszDirectory);
// hKey : HKEY
// pszValue : LPCSTR optional
// pszOutBuf : LPSTR optional, out
// cbOutBuf : DWORD
// pcbData : DWORD* optional, out
// Flags : DWORD
// pszDirectory : LPCSTR 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.ASCII_OPTIONS);
int RegLoadMUIStringA(
Pointer hKey, // HKEY
String pszValue, // LPCSTR optional
byte[] pszOutBuf, // LPSTR optional, out
int cbOutBuf, // DWORD
IntByReference pcbData, // DWORD* optional, out
int Flags, // DWORD
String pszDirectory // LPCSTR optional
);
}@[Link("advapi32")]
lib LibADVAPI32
fun RegLoadMUIStringA = RegLoadMUIStringA(
hKey : Void*, # HKEY
pszValue : UInt8*, # LPCSTR optional
pszOutBuf : UInt8*, # LPSTR optional, out
cbOutBuf : UInt32, # DWORD
pcbData : UInt32*, # DWORD* optional, out
Flags : UInt32, # DWORD
pszDirectory : UInt8* # LPCSTR optional
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RegLoadMUIStringANative = Uint32 Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, Uint32, Pointer<Uint32>, Uint32, Pointer<Utf8>);
typedef RegLoadMUIStringADart = int Function(Pointer<Void>, Pointer<Utf8>, Pointer<Utf8>, int, Pointer<Uint32>, int, Pointer<Utf8>);
final RegLoadMUIStringA = DynamicLibrary.open('ADVAPI32.dll')
.lookupFunction<RegLoadMUIStringANative, RegLoadMUIStringADart>('RegLoadMUIStringA');
// hKey : HKEY -> Pointer<Void>
// pszValue : LPCSTR optional -> Pointer<Utf8>
// pszOutBuf : LPSTR optional, out -> Pointer<Utf8>
// cbOutBuf : DWORD -> Uint32
// pcbData : DWORD* optional, out -> Pointer<Uint32>
// Flags : DWORD -> Uint32
// pszDirectory : LPCSTR optional -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RegLoadMUIStringA(
hKey: THandle; // HKEY
pszValue: PAnsiChar; // LPCSTR optional
pszOutBuf: PAnsiChar; // LPSTR optional, out
cbOutBuf: DWORD; // DWORD
pcbData: Pointer; // DWORD* optional, out
Flags: DWORD; // DWORD
pszDirectory: PAnsiChar // LPCSTR optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'RegLoadMUIStringA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RegLoadMUIStringA"
c_RegLoadMUIStringA :: Ptr () -> CString -> CString -> Word32 -> Ptr Word32 -> Word32 -> CString -> IO Word32
-- hKey : HKEY -> Ptr ()
-- pszValue : LPCSTR optional -> CString
-- pszOutBuf : LPSTR optional, out -> CString
-- cbOutBuf : DWORD -> Word32
-- pcbData : DWORD* optional, out -> Ptr Word32
-- Flags : DWORD -> Word32
-- pszDirectory : LPCSTR optional -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let regloadmuistringa =
foreign "RegLoadMUIStringA"
((ptr void) @-> string @-> string @-> uint32_t @-> (ptr uint32_t) @-> uint32_t @-> string @-> returning uint32_t)
(* hKey : HKEY -> (ptr void) *)
(* pszValue : LPCSTR optional -> string *)
(* pszOutBuf : LPSTR optional, out -> string *)
(* cbOutBuf : DWORD -> uint32_t *)
(* pcbData : DWORD* optional, out -> (ptr uint32_t) *)
(* Flags : DWORD -> uint32_t *)
(* pszDirectory : LPCSTR optional -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advapi32 (t "ADVAPI32.dll"))
(cffi:use-foreign-library advapi32)
(cffi:defcfun ("RegLoadMUIStringA" reg-load-muistring-a :convention :stdcall) :uint32
(h-key :pointer) ; HKEY
(psz-value :string) ; LPCSTR optional
(psz-out-buf :pointer) ; LPSTR optional, out
(cb-out-buf :uint32) ; DWORD
(pcb-data :pointer) ; DWORD* optional, out
(flags :uint32) ; DWORD
(psz-directory :string)) ; LPCSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RegLoadMUIStringA = Win32::API::More->new('ADVAPI32',
'DWORD RegLoadMUIStringA(HANDLE hKey, LPCSTR pszValue, LPSTR pszOutBuf, DWORD cbOutBuf, LPVOID pcbData, DWORD Flags, LPCSTR pszDirectory)');
# my $ret = $RegLoadMUIStringA->Call($hKey, $pszValue, $pszOutBuf, $cbOutBuf, $pcbData, $Flags, $pszDirectory);
# hKey : HKEY -> HANDLE
# pszValue : LPCSTR optional -> LPCSTR
# pszOutBuf : LPSTR optional, out -> LPSTR
# cbOutBuf : DWORD -> DWORD
# pcbData : DWORD* optional, out -> LPVOID
# Flags : DWORD -> DWORD
# pszDirectory : LPCSTR optional -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f RegLoadMUIStringW (Unicode版) — レジストリ値からローカライズされた文字列を読み込む。