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