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