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

RegDeleteValueA

関数
指定したレジストリ値を削除する。
DLLADVAPI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

WIN32_ERROR RegDeleteValueA(
    HKEY hKey,
    LPCSTR lpValueName   // optional
);

パラメーター

名前方向
hKeyHKEYin
lpValueNameLPCSTRinoptional

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

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

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

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

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procRegDeleteValueA = advapi32.NewProc("RegDeleteValueA")
)

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