ホーム › System.Registry › RegDeleteValueW
RegDeleteValueW
関数指定したレジストリ値を削除する。
シグネチャ
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR RegDeleteValueW(
HKEY hKey,
LPCWSTR lpValueName // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hKey | HKEY | in |
| lpValueName | LPCWSTR | inoptional |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
WIN32_ERROR RegDeleteValueW(
HKEY hKey,
LPCWSTR lpValueName // optional
);[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint RegDeleteValueW(
IntPtr hKey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string lpValueName // LPCWSTR optional
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RegDeleteValueW(
hKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> lpValueName As String ' LPCWSTR optional
) As UInteger
End Function' hKey : HKEY
' lpValueName : LPCWSTR optional
Declare PtrSafe Function RegDeleteValueW Lib "advapi32" ( _
ByVal hKey As LongPtr, _
ByVal lpValueName As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegDeleteValueW = ctypes.windll.advapi32.RegDeleteValueW
RegDeleteValueW.restype = wintypes.DWORD
RegDeleteValueW.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.LPCWSTR, # lpValueName : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
RegDeleteValueW = Fiddle::Function.new(
lib['RegDeleteValueW'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
Fiddle::TYPE_VOIDP, # lpValueName : LPCWSTR optional
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advapi32")]
extern "system" {
fn RegDeleteValueW(
hKey: *mut core::ffi::c_void, // HKEY
lpValueName: *const u16 // LPCWSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode)]
public static extern uint RegDeleteValueW(IntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string lpValueName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_RegDeleteValueW' -Namespace Win32 -PassThru
# $api::RegDeleteValueW(hKey, lpValueName)#uselib "ADVAPI32.dll"
#func global RegDeleteValueW "RegDeleteValueW" wptr, wptr
; RegDeleteValueW hKey, lpValueName ; 戻り値は stat
; hKey : HKEY -> "wptr"
; lpValueName : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global RegDeleteValueW "RegDeleteValueW" sptr, wstr
; res = RegDeleteValueW(hKey, lpValueName)
; hKey : HKEY -> "sptr"
; lpValueName : LPCWSTR optional -> "wstr"; WIN32_ERROR RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
#uselib "ADVAPI32.dll"
#cfunc global RegDeleteValueW "RegDeleteValueW" intptr, wstr
; res = RegDeleteValueW(hKey, lpValueName)
; hKey : HKEY -> "intptr"
; lpValueName : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procRegDeleteValueW = advapi32.NewProc("RegDeleteValueW")
)
// hKey (HKEY), lpValueName (LPCWSTR optional)
r1, _, err := procRegDeleteValueW.Call(
uintptr(hKey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpValueName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction RegDeleteValueW(
hKey: THandle; // HKEY
lpValueName: PWideChar // LPCWSTR optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'RegDeleteValueW';result := DllCall("ADVAPI32\RegDeleteValueW"
, "Ptr", hKey ; HKEY
, "WStr", lpValueName ; LPCWSTR optional
, "UInt") ; return: WIN32_ERROR●RegDeleteValueW(hKey, lpValueName) = DLL("ADVAPI32.dll", "dword RegDeleteValueW(void*, char*)")
# 呼び出し: RegDeleteValueW(hKey, lpValueName)
# hKey : HKEY -> "void*"
# lpValueName : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。