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

RegUnLoadKeyA

関数
読み込み済みのハイブをレジストリからアンロードする。
DLLADVAPI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

WIN32_ERROR RegUnLoadKeyA(
    HKEY hKey,
    LPCSTR lpSubKey   // optional
);

パラメーター

名前方向
hKeyHKEYin
lpSubKeyLPCSTRinoptional

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('ADVAPI32.dll')
RegUnLoadKeyA = Fiddle::Function.new(
  lib['RegUnLoadKeyA'],
  [
    Fiddle::TYPE_VOIDP,  # hKey : HKEY
    Fiddle::TYPE_VOIDP,  # lpSubKey : LPCSTR optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn RegUnLoadKeyA(
        hKey: *mut core::ffi::c_void,  // HKEY
        lpSubKey: *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 RegUnLoadKeyA(IntPtr hKey, [MarshalAs(UnmanagedType.LPStr)] string lpSubKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegUnLoadKeyA' -Namespace Win32 -PassThru
# $api::RegUnLoadKeyA(hKey, lpSubKey)
#uselib "ADVAPI32.dll"
#func global RegUnLoadKeyA "RegUnLoadKeyA" sptr, sptr
; RegUnLoadKeyA hKey, lpSubKey   ; 戻り値は stat
; hKey : HKEY -> "sptr"
; lpSubKey : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global RegUnLoadKeyA "RegUnLoadKeyA" sptr, str
; res = RegUnLoadKeyA(hKey, lpSubKey)
; hKey : HKEY -> "sptr"
; lpSubKey : LPCSTR optional -> "str"
; WIN32_ERROR RegUnLoadKeyA(HKEY hKey, LPCSTR lpSubKey)
#uselib "ADVAPI32.dll"
#cfunc global RegUnLoadKeyA "RegUnLoadKeyA" intptr, str
; res = RegUnLoadKeyA(hKey, lpSubKey)
; hKey : HKEY -> "intptr"
; lpSubKey : LPCSTR optional -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procRegUnLoadKeyA = advapi32.NewProc("RegUnLoadKeyA")
)

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