Win32 API 日本語リファレンス
ホームNetworking.Clustering › ClusterRegDeleteKeyEx

ClusterRegDeleteKeyEx

関数
理由付きでクラスターレジストリのサブキーを削除する。
DLLCLUSAPI.dll呼出規約winapi

シグネチャ

// CLUSAPI.dll
#include <windows.h>

INT ClusterRegDeleteKeyEx(
    HKEY hKey,
    LPCWSTR lpSubKey,
    LPCWSTR lpszReason   // optional
);

パラメーター

名前方向
hKeyHKEYin
lpSubKeyLPCWSTRin
lpszReasonLPCWSTRinoptional

戻り値の型: INT

各言語での呼び出し定義

// CLUSAPI.dll
#include <windows.h>

INT ClusterRegDeleteKeyEx(
    HKEY hKey,
    LPCWSTR lpSubKey,
    LPCWSTR lpszReason   // optional
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegDeleteKeyEx(
    IntPtr hKey,   // HKEY
    [MarshalAs(UnmanagedType.LPWStr)] string lpSubKey,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string lpszReason   // LPCWSTR optional
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegDeleteKeyEx(
    hKey As IntPtr,   ' HKEY
    <MarshalAs(UnmanagedType.LPWStr)> lpSubKey As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszReason As String   ' LPCWSTR optional
) As Integer
End Function
' hKey : HKEY
' lpSubKey : LPCWSTR
' lpszReason : LPCWSTR optional
Declare PtrSafe Function ClusterRegDeleteKeyEx Lib "clusapi" ( _
    ByVal hKey As LongPtr, _
    ByVal lpSubKey As LongPtr, _
    ByVal lpszReason As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterRegDeleteKeyEx = ctypes.windll.clusapi.ClusterRegDeleteKeyEx
ClusterRegDeleteKeyEx.restype = ctypes.c_int
ClusterRegDeleteKeyEx.argtypes = [
    wintypes.HANDLE,  # hKey : HKEY
    wintypes.LPCWSTR,  # lpSubKey : LPCWSTR
    wintypes.LPCWSTR,  # lpszReason : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegDeleteKeyEx = Fiddle::Function.new(
  lib['ClusterRegDeleteKeyEx'],
  [
    Fiddle::TYPE_VOIDP,  # hKey : HKEY
    Fiddle::TYPE_VOIDP,  # lpSubKey : LPCWSTR
    Fiddle::TYPE_VOIDP,  # lpszReason : LPCWSTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterRegDeleteKeyEx(
        hKey: *mut core::ffi::c_void,  // HKEY
        lpSubKey: *const u16,  // LPCWSTR
        lpszReason: *const u16  // LPCWSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegDeleteKeyEx(IntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string lpSubKey, [MarshalAs(UnmanagedType.LPWStr)] string lpszReason);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegDeleteKeyEx' -Namespace Win32 -PassThru
# $api::ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason)
#uselib "CLUSAPI.dll"
#func global ClusterRegDeleteKeyEx "ClusterRegDeleteKeyEx" sptr, sptr, sptr
; ClusterRegDeleteKeyEx hKey, lpSubKey, lpszReason   ; 戻り値は stat
; hKey : HKEY -> "sptr"
; lpSubKey : LPCWSTR -> "sptr"
; lpszReason : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegDeleteKeyEx "ClusterRegDeleteKeyEx" sptr, wstr, wstr
; res = ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason)
; hKey : HKEY -> "sptr"
; lpSubKey : LPCWSTR -> "wstr"
; lpszReason : LPCWSTR optional -> "wstr"
; INT ClusterRegDeleteKeyEx(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpszReason)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegDeleteKeyEx "ClusterRegDeleteKeyEx" intptr, wstr, wstr
; res = ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason)
; hKey : HKEY -> "intptr"
; lpSubKey : LPCWSTR -> "wstr"
; lpszReason : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterRegDeleteKeyEx = clusapi.NewProc("ClusterRegDeleteKeyEx")
)

// hKey (HKEY), lpSubKey (LPCWSTR), lpszReason (LPCWSTR optional)
r1, _, err := procClusterRegDeleteKeyEx.Call(
	uintptr(hKey),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpSubKey))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszReason))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ClusterRegDeleteKeyEx(
  hKey: THandle;   // HKEY
  lpSubKey: PWideChar;   // LPCWSTR
  lpszReason: PWideChar   // LPCWSTR optional
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegDeleteKeyEx';
result := DllCall("CLUSAPI\ClusterRegDeleteKeyEx"
    , "Ptr", hKey   ; HKEY
    , "WStr", lpSubKey   ; LPCWSTR
    , "WStr", lpszReason   ; LPCWSTR optional
    , "Int")   ; return: INT
●ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason) = DLL("CLUSAPI.dll", "int ClusterRegDeleteKeyEx(void*, char*, char*)")
# 呼び出し: ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason)
# hKey : HKEY -> "void*"
# lpSubKey : LPCWSTR -> "char*"
# lpszReason : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。