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