ホーム › Networking.Clustering › ClusterRegSetKeySecurity
ClusterRegSetKeySecurity
関数クラスタレジストリキーにセキュリティ記述子を設定する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegSetKeySecurity(
HKEY hKey,
DWORD SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hKey | HKEY | in |
| SecurityInformation | DWORD | in |
| pSecurityDescriptor | PSECURITY_DESCRIPTOR | in |
戻り値の型: INT
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegSetKeySecurity(
HKEY hKey,
DWORD SecurityInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor
);[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegSetKeySecurity(
IntPtr hKey, // HKEY
uint SecurityInformation, // DWORD
IntPtr pSecurityDescriptor // PSECURITY_DESCRIPTOR
);<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegSetKeySecurity(
hKey As IntPtr, ' HKEY
SecurityInformation As UInteger, ' DWORD
pSecurityDescriptor As IntPtr ' PSECURITY_DESCRIPTOR
) As Integer
End Function' hKey : HKEY
' SecurityInformation : DWORD
' pSecurityDescriptor : PSECURITY_DESCRIPTOR
Declare PtrSafe Function ClusterRegSetKeySecurity Lib "clusapi" ( _
ByVal hKey As LongPtr, _
ByVal SecurityInformation As Long, _
ByVal pSecurityDescriptor As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ClusterRegSetKeySecurity = ctypes.windll.clusapi.ClusterRegSetKeySecurity
ClusterRegSetKeySecurity.restype = ctypes.c_int
ClusterRegSetKeySecurity.argtypes = [
wintypes.HANDLE, # hKey : HKEY
wintypes.DWORD, # SecurityInformation : DWORD
wintypes.HANDLE, # pSecurityDescriptor : PSECURITY_DESCRIPTOR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegSetKeySecurity = Fiddle::Function.new(
lib['ClusterRegSetKeySecurity'],
[
Fiddle::TYPE_VOIDP, # hKey : HKEY
-Fiddle::TYPE_INT, # SecurityInformation : DWORD
Fiddle::TYPE_VOIDP, # pSecurityDescriptor : PSECURITY_DESCRIPTOR
],
Fiddle::TYPE_INT)#[link(name = "clusapi")]
extern "system" {
fn ClusterRegSetKeySecurity(
hKey: *mut core::ffi::c_void, // HKEY
SecurityInformation: u32, // DWORD
pSecurityDescriptor: *mut core::ffi::c_void // PSECURITY_DESCRIPTOR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegSetKeySecurity(IntPtr hKey, uint SecurityInformation, IntPtr pSecurityDescriptor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegSetKeySecurity' -Namespace Win32 -PassThru
# $api::ClusterRegSetKeySecurity(hKey, SecurityInformation, pSecurityDescriptor)#uselib "CLUSAPI.dll"
#func global ClusterRegSetKeySecurity "ClusterRegSetKeySecurity" sptr, sptr, sptr
; ClusterRegSetKeySecurity hKey, SecurityInformation, pSecurityDescriptor ; 戻り値は stat
; hKey : HKEY -> "sptr"
; SecurityInformation : DWORD -> "sptr"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CLUSAPI.dll"
#cfunc global ClusterRegSetKeySecurity "ClusterRegSetKeySecurity" sptr, int, sptr
; res = ClusterRegSetKeySecurity(hKey, SecurityInformation, pSecurityDescriptor)
; hKey : HKEY -> "sptr"
; SecurityInformation : DWORD -> "int"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr"; INT ClusterRegSetKeySecurity(HKEY hKey, DWORD SecurityInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegSetKeySecurity "ClusterRegSetKeySecurity" intptr, int, intptr
; res = ClusterRegSetKeySecurity(hKey, SecurityInformation, pSecurityDescriptor)
; hKey : HKEY -> "intptr"
; SecurityInformation : DWORD -> "int"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procClusterRegSetKeySecurity = clusapi.NewProc("ClusterRegSetKeySecurity")
)
// hKey (HKEY), SecurityInformation (DWORD), pSecurityDescriptor (PSECURITY_DESCRIPTOR)
r1, _, err := procClusterRegSetKeySecurity.Call(
uintptr(hKey),
uintptr(SecurityInformation),
uintptr(pSecurityDescriptor),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ClusterRegSetKeySecurity(
hKey: THandle; // HKEY
SecurityInformation: DWORD; // DWORD
pSecurityDescriptor: THandle // PSECURITY_DESCRIPTOR
): Integer; stdcall;
external 'CLUSAPI.dll' name 'ClusterRegSetKeySecurity';result := DllCall("CLUSAPI\ClusterRegSetKeySecurity"
, "Ptr", hKey ; HKEY
, "UInt", SecurityInformation ; DWORD
, "Ptr", pSecurityDescriptor ; PSECURITY_DESCRIPTOR
, "Int") ; return: INT●ClusterRegSetKeySecurity(hKey, SecurityInformation, pSecurityDescriptor) = DLL("CLUSAPI.dll", "int ClusterRegSetKeySecurity(void*, dword, void*)")
# 呼び出し: ClusterRegSetKeySecurity(hKey, SecurityInformation, pSecurityDescriptor)
# hKey : HKEY -> "void*"
# SecurityInformation : DWORD -> "dword"
# pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。