ホーム › 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 |
戻り値の型: 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)。