ホーム › System.Registry › RegDeleteKeyA
RegDeleteKeyA
関数指定したサブキーをレジストリから削除する。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR RegDeleteKeyA(
HKEY hKey,
LPCSTR lpSubKey
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hKey | HKEY | in |
| lpSubKey | LPCSTR | in |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR RegDeleteKeyA(
HKEY hKey,
LPCSTR lpSubKey
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint RegDeleteKeyA(
IntPtr hKey, // HKEY
[MarshalAs(UnmanagedType.LPStr)] string lpSubKey // LPCSTR
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RegDeleteKeyA(
hKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPStr)> lpSubKey As String ' LPCSTR
) As UInteger
End Function' hKey : HKEY
' lpSubKey : LPCSTR
Declare PtrSafe Function RegDeleteKeyA 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
RegDeleteKeyA = ctypes.windll.advapi32.RegDeleteKeyA
RegDeleteKeyA.restype = wintypes.DWORD
RegDeleteKeyA.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.LPCSTR, # lpSubKey : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
RegDeleteKeyA = Fiddle::Function.new(
lib['RegDeleteKeyA'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
Fiddle::TYPE_VOIDP, # lpSubKey : LPCSTR
],
-Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn RegDeleteKeyA(
hKey: *mut core::ffi::c_void, // HKEY
lpSubKey: *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 RegDeleteKeyA(IntPtr hKey, [MarshalAs(UnmanagedType.LPStr)] string lpSubKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegDeleteKeyA' -Namespace Win32 -PassThru
# $api::RegDeleteKeyA(hKey, lpSubKey)#uselib "ADVAPI32.dll"
#func global RegDeleteKeyA "RegDeleteKeyA" sptr, sptr
; RegDeleteKeyA hKey, lpSubKey ; 戻り値は stat
; hKey : HKEY -> "sptr"
; lpSubKey : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global RegDeleteKeyA "RegDeleteKeyA" sptr, str
; res = RegDeleteKeyA(hKey, lpSubKey)
; hKey : HKEY -> "sptr"
; lpSubKey : LPCSTR -> "str"; WIN32_ERROR RegDeleteKeyA(HKEY hKey, LPCSTR lpSubKey)
#uselib "ADVAPI32.dll"
#cfunc global RegDeleteKeyA "RegDeleteKeyA" intptr, str
; res = RegDeleteKeyA(hKey, lpSubKey)
; hKey : HKEY -> "intptr"
; lpSubKey : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procRegDeleteKeyA = advapi32.NewProc("RegDeleteKeyA")
)
// hKey (HKEY), lpSubKey (LPCSTR)
r1, _, err := procRegDeleteKeyA.Call(
uintptr(hKey),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpSubKey))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction RegDeleteKeyA(
hKey: THandle; // HKEY
lpSubKey: PAnsiChar // LPCSTR
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'RegDeleteKeyA';result := DllCall("ADVAPI32\RegDeleteKeyA"
, "Ptr", hKey ; HKEY
, "AStr", lpSubKey ; LPCSTR
, "UInt") ; return: WIN32_ERROR●RegDeleteKeyA(hKey, lpSubKey) = DLL("ADVAPI32.dll", "dword RegDeleteKeyA(void*, char*)")
# 呼び出し: RegDeleteKeyA(hKey, lpSubKey)
# hKey : HKEY -> "void*"
# lpSubKey : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。