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