ホーム › Networking.Clustering › ClusterRegDeleteKey
ClusterRegDeleteKey
関数クラスターレジストリのサブキーを削除する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegDeleteKey(
HKEY hKey,
LPCWSTR lpszSubKey
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hKey | HKEY | in | 削除するサブキーの親となる開いているクラスターレジストリキー。 |
| lpszSubKey | LPCWSTR | in | 削除するサブキーの名前を示すワイド文字列。 |
戻り値の型: INT
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegDeleteKey(
HKEY hKey,
LPCWSTR lpszSubKey
);[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegDeleteKey(
IntPtr hKey, // HKEY
[MarshalAs(UnmanagedType.LPWStr)] string lpszSubKey // LPCWSTR
);<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegDeleteKey(
hKey As IntPtr, ' HKEY
<MarshalAs(UnmanagedType.LPWStr)> lpszSubKey As String ' LPCWSTR
) As Integer
End Function' hKey : HKEY
' lpszSubKey : LPCWSTR
Declare PtrSafe Function ClusterRegDeleteKey Lib "clusapi" ( _
ByVal hKey As LongPtr, _
ByVal lpszSubKey As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ClusterRegDeleteKey = ctypes.windll.clusapi.ClusterRegDeleteKey
ClusterRegDeleteKey.restype = ctypes.c_int
ClusterRegDeleteKey.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.LPCWSTR, # lpszSubKey : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegDeleteKey = Fiddle::Function.new(
lib['ClusterRegDeleteKey'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
Fiddle::TYPE_VOIDP, # lpszSubKey : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "clusapi")]
extern "system" {
fn ClusterRegDeleteKey(
hKey: *mut core::ffi::c_void, // HKEY
lpszSubKey: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegDeleteKey(IntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string lpszSubKey);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegDeleteKey' -Namespace Win32 -PassThru
# $api::ClusterRegDeleteKey(hKey, lpszSubKey)#uselib "CLUSAPI.dll"
#func global ClusterRegDeleteKey "ClusterRegDeleteKey" sptr, sptr
; ClusterRegDeleteKey hKey, lpszSubKey ; 戻り値は stat
; hKey : HKEY -> "sptr"
; lpszSubKey : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CLUSAPI.dll"
#cfunc global ClusterRegDeleteKey "ClusterRegDeleteKey" sptr, wstr
; res = ClusterRegDeleteKey(hKey, lpszSubKey)
; hKey : HKEY -> "sptr"
; lpszSubKey : LPCWSTR -> "wstr"; INT ClusterRegDeleteKey(HKEY hKey, LPCWSTR lpszSubKey)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegDeleteKey "ClusterRegDeleteKey" intptr, wstr
; res = ClusterRegDeleteKey(hKey, lpszSubKey)
; hKey : HKEY -> "intptr"
; lpszSubKey : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procClusterRegDeleteKey = clusapi.NewProc("ClusterRegDeleteKey")
)
// hKey (HKEY), lpszSubKey (LPCWSTR)
r1, _, err := procClusterRegDeleteKey.Call(
uintptr(hKey),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszSubKey))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ClusterRegDeleteKey(
hKey: THandle; // HKEY
lpszSubKey: PWideChar // LPCWSTR
): Integer; stdcall;
external 'CLUSAPI.dll' name 'ClusterRegDeleteKey';result := DllCall("CLUSAPI\ClusterRegDeleteKey"
, "Ptr", hKey ; HKEY
, "WStr", lpszSubKey ; LPCWSTR
, "Int") ; return: INT●ClusterRegDeleteKey(hKey, lpszSubKey) = DLL("CLUSAPI.dll", "int ClusterRegDeleteKey(void*, char*)")
# 呼び出し: ClusterRegDeleteKey(hKey, lpszSubKey)
# hKey : HKEY -> "void*"
# lpszSubKey : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "clusapi" fn ClusterRegDeleteKey(
hKey: ?*anyopaque, // HKEY
lpszSubKey: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc ClusterRegDeleteKey(
hKey: pointer, # HKEY
lpszSubKey: WideCString # LPCWSTR
): int32 {.importc: "ClusterRegDeleteKey", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
int ClusterRegDeleteKey(
void* hKey, // HKEY
const(wchar)* lpszSubKey // LPCWSTR
);ccall((:ClusterRegDeleteKey, "CLUSAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring),
hKey, lpszSubKey)
# hKey : HKEY -> Ptr{Cvoid}
# lpszSubKey : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ClusterRegDeleteKey(
void* hKey,
const uint16_t* lpszSubKey);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterRegDeleteKey(hKey, lpszSubKey)
-- hKey : HKEY
-- lpszSubKey : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterRegDeleteKey = lib.func('__stdcall', 'ClusterRegDeleteKey', 'int32_t', ['void *', 'str16']);
// ClusterRegDeleteKey(hKey, lpszSubKey)
// hKey : HKEY -> 'void *'
// lpszSubKey : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
ClusterRegDeleteKey: { parameters: ["pointer", "buffer"], result: "i32" },
});
// lib.symbols.ClusterRegDeleteKey(hKey, lpszSubKey)
// hKey : HKEY -> "pointer"
// lpszSubKey : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ClusterRegDeleteKey(
void* hKey,
const uint16_t* lpszSubKey);
C, "CLUSAPI.dll");
// $ffi->ClusterRegDeleteKey(hKey, lpszSubKey);
// hKey : HKEY
// lpszSubKey : LPCWSTR
// 構造体/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 ClusterRegDeleteKey(
Pointer hKey, // HKEY
WString lpszSubKey // LPCWSTR
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun ClusterRegDeleteKey = ClusterRegDeleteKey(
hKey : Void*, # HKEY
lpszSubKey : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ClusterRegDeleteKeyNative = Int32 Function(Pointer<Void>, Pointer<Utf16>);
typedef ClusterRegDeleteKeyDart = int Function(Pointer<Void>, Pointer<Utf16>);
final ClusterRegDeleteKey = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<ClusterRegDeleteKeyNative, ClusterRegDeleteKeyDart>('ClusterRegDeleteKey');
// hKey : HKEY -> Pointer<Void>
// lpszSubKey : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ClusterRegDeleteKey(
hKey: THandle; // HKEY
lpszSubKey: PWideChar // LPCWSTR
): Integer; stdcall;
external 'CLUSAPI.dll' name 'ClusterRegDeleteKey';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ClusterRegDeleteKey"
c_ClusterRegDeleteKey :: Ptr () -> CWString -> IO Int32
-- hKey : HKEY -> Ptr ()
-- lpszSubKey : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let clusterregdeletekey =
foreign "ClusterRegDeleteKey"
((ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* hKey : HKEY -> (ptr void) *)
(* lpszSubKey : LPCWSTR -> (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 ("ClusterRegDeleteKey" cluster-reg-delete-key :convention :stdcall) :int32
(h-key :pointer) ; HKEY
(lpsz-sub-key (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ClusterRegDeleteKey = Win32::API::More->new('CLUSAPI',
'int ClusterRegDeleteKey(HANDLE hKey, LPCWSTR lpszSubKey)');
# my $ret = $ClusterRegDeleteKey->Call($hKey, $lpszSubKey);
# hKey : HKEY -> HANDLE
# lpszSubKey : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f ClusterRegDeleteKeyEx — 理由付きでクラスターレジストリのサブキーを削除する。