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