ホーム › Networking.Clustering › ClusterRegDeleteKeyEx
ClusterRegDeleteKeyEx
関数理由付きでクラスターレジストリのサブキーを削除する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegDeleteKeyEx(
HKEY hKey,
LPCWSTR lpSubKey,
LPCWSTR lpszReason // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hKey | HKEY | in | 削除するサブキーの親となる開いているクラスターレジストリキー。 |
| lpSubKey | LPCWSTR | in | 削除するサブキーの名前を示すワイド文字列。 |
| lpszReason | LPCWSTR | inoptional | 操作理由を示すワイド文字列。監査ログ用でNULL可。 |
戻り値の型: 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 // INTfunction 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)。const std = @import("std");
extern "clusapi" fn ClusterRegDeleteKeyEx(
hKey: ?*anyopaque, // HKEY
lpSubKey: [*c]const u16, // LPCWSTR
lpszReason: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) i32;proc ClusterRegDeleteKeyEx(
hKey: pointer, # HKEY
lpSubKey: WideCString, # LPCWSTR
lpszReason: WideCString # LPCWSTR optional
): int32 {.importc: "ClusterRegDeleteKeyEx", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
int ClusterRegDeleteKeyEx(
void* hKey, // HKEY
const(wchar)* lpSubKey, // LPCWSTR
const(wchar)* lpszReason // LPCWSTR optional
);ccall((:ClusterRegDeleteKeyEx, "CLUSAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Cwstring),
hKey, lpSubKey, lpszReason)
# hKey : HKEY -> Ptr{Cvoid}
# lpSubKey : LPCWSTR -> Cwstring
# lpszReason : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ClusterRegDeleteKeyEx(
void* hKey,
const uint16_t* lpSubKey,
const uint16_t* lpszReason);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason)
-- hKey : HKEY
-- lpSubKey : LPCWSTR
-- lpszReason : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterRegDeleteKeyEx = lib.func('__stdcall', 'ClusterRegDeleteKeyEx', 'int32_t', ['void *', 'str16', 'str16']);
// ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason)
// hKey : HKEY -> 'void *'
// lpSubKey : LPCWSTR -> 'str16'
// lpszReason : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
ClusterRegDeleteKeyEx: { parameters: ["pointer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason)
// hKey : HKEY -> "pointer"
// lpSubKey : LPCWSTR -> "buffer"
// lpszReason : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ClusterRegDeleteKeyEx(
void* hKey,
const uint16_t* lpSubKey,
const uint16_t* lpszReason);
C, "CLUSAPI.dll");
// $ffi->ClusterRegDeleteKeyEx(hKey, lpSubKey, lpszReason);
// hKey : HKEY
// lpSubKey : LPCWSTR
// lpszReason : LPCWSTR optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Clusapi extends StdCallLibrary {
Clusapi INSTANCE = Native.load("clusapi", Clusapi.class);
int ClusterRegDeleteKeyEx(
Pointer hKey, // HKEY
WString lpSubKey, // LPCWSTR
WString lpszReason // LPCWSTR optional
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun ClusterRegDeleteKeyEx = ClusterRegDeleteKeyEx(
hKey : Void*, # HKEY
lpSubKey : UInt16*, # LPCWSTR
lpszReason : UInt16* # LPCWSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ClusterRegDeleteKeyExNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>);
typedef ClusterRegDeleteKeyExDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>);
final ClusterRegDeleteKeyEx = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<ClusterRegDeleteKeyExNative, ClusterRegDeleteKeyExDart>('ClusterRegDeleteKeyEx');
// hKey : HKEY -> Pointer<Void>
// lpSubKey : LPCWSTR -> Pointer<Utf16>
// lpszReason : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ClusterRegDeleteKeyEx(
hKey: THandle; // HKEY
lpSubKey: PWideChar; // LPCWSTR
lpszReason: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'CLUSAPI.dll' name 'ClusterRegDeleteKeyEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ClusterRegDeleteKeyEx"
c_ClusterRegDeleteKeyEx :: Ptr () -> CWString -> CWString -> IO Int32
-- hKey : HKEY -> Ptr ()
-- lpSubKey : LPCWSTR -> CWString
-- lpszReason : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let clusterregdeletekeyex =
foreign "ClusterRegDeleteKeyEx"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hKey : HKEY -> (ptr void) *)
(* lpSubKey : LPCWSTR -> (ptr uint16_t) *)
(* lpszReason : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)
(cffi:defcfun ("ClusterRegDeleteKeyEx" cluster-reg-delete-key-ex :convention :stdcall) :int32
(h-key :pointer) ; HKEY
(lp-sub-key (:string :encoding :utf-16le)) ; LPCWSTR
(lpsz-reason (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ClusterRegDeleteKeyEx = Win32::API::More->new('CLUSAPI',
'int ClusterRegDeleteKeyEx(HANDLE hKey, LPCWSTR lpSubKey, LPCWSTR lpszReason)');
# my $ret = $ClusterRegDeleteKeyEx->Call($hKey, $lpSubKey, $lpszReason);
# hKey : HKEY -> HANDLE
# lpSubKey : LPCWSTR -> LPCWSTR
# lpszReason : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f ClusterRegDeleteKey — クラスターレジストリのサブキーを削除する。