Win32 API 日本語リファレンス
ホームSystem.Registry › RegLoadKeyA

RegLoadKeyA

関数
ハイブファイルをレジストリのサブキーとして読み込む。
DLLADVAPI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR RegLoadKeyA(
    HKEY hKey,
    LPCSTR lpSubKey,   // optional
    LPCSTR lpFile
);

パラメーター

名前方向
hKeyHKEYin
lpSubKeyLPCSTRinoptional
lpFileLPCSTRin

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR RegLoadKeyA(
    HKEY hKey,
    LPCSTR lpSubKey,   // optional
    LPCSTR lpFile
);
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint RegLoadKeyA(
    IntPtr hKey,   // HKEY
    [MarshalAs(UnmanagedType.LPStr)] string lpSubKey,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string lpFile   // LPCSTR
);
<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RegLoadKeyA(
    hKey As IntPtr,   ' HKEY
    <MarshalAs(UnmanagedType.LPStr)> lpSubKey As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> lpFile As String   ' LPCSTR
) As UInteger
End Function
' hKey : HKEY
' lpSubKey : LPCSTR optional
' lpFile : LPCSTR
Declare PtrSafe Function RegLoadKeyA Lib "advapi32" ( _
    ByVal hKey As LongPtr, _
    ByVal lpSubKey As String, _
    ByVal lpFile As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RegLoadKeyA = ctypes.windll.advapi32.RegLoadKeyA
RegLoadKeyA.restype = wintypes.DWORD
RegLoadKeyA.argtypes = [
    wintypes.HANDLE,  # hKey : HKEY
    wintypes.LPCSTR,  # lpSubKey : LPCSTR optional
    wintypes.LPCSTR,  # lpFile : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
RegLoadKeyA = Fiddle::Function.new(
  lib['RegLoadKeyA'],
  [
    Fiddle::TYPE_VOIDP,  # hKey : HKEY
    Fiddle::TYPE_VOIDP,  # lpSubKey : LPCSTR optional
    Fiddle::TYPE_VOIDP,  # lpFile : LPCSTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn RegLoadKeyA(
        hKey: *mut core::ffi::c_void,  // HKEY
        lpSubKey: *const u8,  // LPCSTR optional
        lpFile: *const u8  // LPCSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi)]
public static extern uint RegLoadKeyA(IntPtr hKey, [MarshalAs(UnmanagedType.LPStr)] string lpSubKey, [MarshalAs(UnmanagedType.LPStr)] string lpFile);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegLoadKeyA' -Namespace Win32 -PassThru
# $api::RegLoadKeyA(hKey, lpSubKey, lpFile)
#uselib "ADVAPI32.dll"
#func global RegLoadKeyA "RegLoadKeyA" sptr, sptr, sptr
; RegLoadKeyA hKey, lpSubKey, lpFile   ; 戻り値は stat
; hKey : HKEY -> "sptr"
; lpSubKey : LPCSTR optional -> "sptr"
; lpFile : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global RegLoadKeyA "RegLoadKeyA" sptr, str, str
; res = RegLoadKeyA(hKey, lpSubKey, lpFile)
; hKey : HKEY -> "sptr"
; lpSubKey : LPCSTR optional -> "str"
; lpFile : LPCSTR -> "str"
; WIN32_ERROR RegLoadKeyA(HKEY hKey, LPCSTR lpSubKey, LPCSTR lpFile)
#uselib "ADVAPI32.dll"
#cfunc global RegLoadKeyA "RegLoadKeyA" intptr, str, str
; res = RegLoadKeyA(hKey, lpSubKey, lpFile)
; hKey : HKEY -> "intptr"
; lpSubKey : LPCSTR optional -> "str"
; lpFile : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procRegLoadKeyA = advapi32.NewProc("RegLoadKeyA")
)

// hKey (HKEY), lpSubKey (LPCSTR optional), lpFile (LPCSTR)
r1, _, err := procRegLoadKeyA.Call(
	uintptr(hKey),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpSubKey))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpFile))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function RegLoadKeyA(
  hKey: THandle;   // HKEY
  lpSubKey: PAnsiChar;   // LPCSTR optional
  lpFile: PAnsiChar   // LPCSTR
): DWORD; stdcall;
  external 'ADVAPI32.dll' name 'RegLoadKeyA';
result := DllCall("ADVAPI32\RegLoadKeyA"
    , "Ptr", hKey   ; HKEY
    , "AStr", lpSubKey   ; LPCSTR optional
    , "AStr", lpFile   ; LPCSTR
    , "UInt")   ; return: WIN32_ERROR
●RegLoadKeyA(hKey, lpSubKey, lpFile) = DLL("ADVAPI32.dll", "dword RegLoadKeyA(void*, char*, char*)")
# 呼び出し: RegLoadKeyA(hKey, lpSubKey, lpFile)
# hKey : HKEY -> "void*"
# lpSubKey : LPCSTR optional -> "char*"
# lpFile : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。