Win32 API 日本語リファレンス
ホームNetworking.Clustering › ClusterRegGetKeySecurity

ClusterRegGetKeySecurity

関数
クラスタレジストリキーのセキュリティ記述子を取得する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

// CLUSAPI.dll
#include <windows.h>

INT ClusterRegGetKeySecurity(
    HKEY hKey,
    DWORD RequestedInformation,
    PSECURITY_DESCRIPTOR pSecurityDescriptor,
    DWORD* lpcbSecurityDescriptor
);

パラメーター

名前方向
hKeyHKEYin
RequestedInformationDWORDin
pSecurityDescriptorPSECURITY_DESCRIPTORout
lpcbSecurityDescriptorDWORD*inout

戻り値の型: INT

各言語での呼び出し定義

// CLUSAPI.dll
#include <windows.h>

INT ClusterRegGetKeySecurity(
    HKEY hKey,
    DWORD RequestedInformation,
    PSECURITY_DESCRIPTOR pSecurityDescriptor,
    DWORD* lpcbSecurityDescriptor
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegGetKeySecurity(
    IntPtr hKey,   // HKEY
    uint RequestedInformation,   // DWORD
    IntPtr pSecurityDescriptor,   // PSECURITY_DESCRIPTOR out
    ref uint lpcbSecurityDescriptor   // DWORD* in/out
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegGetKeySecurity(
    hKey As IntPtr,   ' HKEY
    RequestedInformation As UInteger,   ' DWORD
    pSecurityDescriptor As IntPtr,   ' PSECURITY_DESCRIPTOR out
    ByRef lpcbSecurityDescriptor As UInteger   ' DWORD* in/out
) As Integer
End Function
' hKey : HKEY
' RequestedInformation : DWORD
' pSecurityDescriptor : PSECURITY_DESCRIPTOR out
' lpcbSecurityDescriptor : DWORD* in/out
Declare PtrSafe Function ClusterRegGetKeySecurity Lib "clusapi" ( _
    ByVal hKey As LongPtr, _
    ByVal RequestedInformation As Long, _
    ByVal pSecurityDescriptor As LongPtr, _
    ByRef lpcbSecurityDescriptor As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterRegGetKeySecurity = ctypes.windll.clusapi.ClusterRegGetKeySecurity
ClusterRegGetKeySecurity.restype = ctypes.c_int
ClusterRegGetKeySecurity.argtypes = [
    wintypes.HANDLE,  # hKey : HKEY
    wintypes.DWORD,  # RequestedInformation : DWORD
    wintypes.HANDLE,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR out
    ctypes.POINTER(wintypes.DWORD),  # lpcbSecurityDescriptor : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegGetKeySecurity = Fiddle::Function.new(
  lib['ClusterRegGetKeySecurity'],
  [
    Fiddle::TYPE_VOIDP,  # hKey : HKEY
    -Fiddle::TYPE_INT,  # RequestedInformation : DWORD
    Fiddle::TYPE_VOIDP,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR out
    Fiddle::TYPE_VOIDP,  # lpcbSecurityDescriptor : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterRegGetKeySecurity(
        hKey: *mut core::ffi::c_void,  // HKEY
        RequestedInformation: u32,  // DWORD
        pSecurityDescriptor: *mut core::ffi::c_void,  // PSECURITY_DESCRIPTOR out
        lpcbSecurityDescriptor: *mut u32  // DWORD* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegGetKeySecurity(IntPtr hKey, uint RequestedInformation, IntPtr pSecurityDescriptor, ref uint lpcbSecurityDescriptor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegGetKeySecurity' -Namespace Win32 -PassThru
# $api::ClusterRegGetKeySecurity(hKey, RequestedInformation, pSecurityDescriptor, lpcbSecurityDescriptor)
#uselib "CLUSAPI.dll"
#func global ClusterRegGetKeySecurity "ClusterRegGetKeySecurity" sptr, sptr, sptr, sptr
; ClusterRegGetKeySecurity hKey, RequestedInformation, pSecurityDescriptor, varptr(lpcbSecurityDescriptor)   ; 戻り値は stat
; hKey : HKEY -> "sptr"
; RequestedInformation : DWORD -> "sptr"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR out -> "sptr"
; lpcbSecurityDescriptor : DWORD* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegGetKeySecurity "ClusterRegGetKeySecurity" sptr, int, sptr, var
; res = ClusterRegGetKeySecurity(hKey, RequestedInformation, pSecurityDescriptor, lpcbSecurityDescriptor)
; hKey : HKEY -> "sptr"
; RequestedInformation : DWORD -> "int"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR out -> "sptr"
; lpcbSecurityDescriptor : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT ClusterRegGetKeySecurity(HKEY hKey, DWORD RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD* lpcbSecurityDescriptor)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegGetKeySecurity "ClusterRegGetKeySecurity" intptr, int, intptr, var
; res = ClusterRegGetKeySecurity(hKey, RequestedInformation, pSecurityDescriptor, lpcbSecurityDescriptor)
; hKey : HKEY -> "intptr"
; RequestedInformation : DWORD -> "int"
; pSecurityDescriptor : PSECURITY_DESCRIPTOR out -> "intptr"
; lpcbSecurityDescriptor : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterRegGetKeySecurity = clusapi.NewProc("ClusterRegGetKeySecurity")
)

// hKey (HKEY), RequestedInformation (DWORD), pSecurityDescriptor (PSECURITY_DESCRIPTOR out), lpcbSecurityDescriptor (DWORD* in/out)
r1, _, err := procClusterRegGetKeySecurity.Call(
	uintptr(hKey),
	uintptr(RequestedInformation),
	uintptr(pSecurityDescriptor),
	uintptr(lpcbSecurityDescriptor),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ClusterRegGetKeySecurity(
  hKey: THandle;   // HKEY
  RequestedInformation: DWORD;   // DWORD
  pSecurityDescriptor: THandle;   // PSECURITY_DESCRIPTOR out
  lpcbSecurityDescriptor: Pointer   // DWORD* in/out
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegGetKeySecurity';
result := DllCall("CLUSAPI\ClusterRegGetKeySecurity"
    , "Ptr", hKey   ; HKEY
    , "UInt", RequestedInformation   ; DWORD
    , "Ptr", pSecurityDescriptor   ; PSECURITY_DESCRIPTOR out
    , "Ptr", lpcbSecurityDescriptor   ; DWORD* in/out
    , "Int")   ; return: INT
●ClusterRegGetKeySecurity(hKey, RequestedInformation, pSecurityDescriptor, lpcbSecurityDescriptor) = DLL("CLUSAPI.dll", "int ClusterRegGetKeySecurity(void*, dword, void*, void*)")
# 呼び出し: ClusterRegGetKeySecurity(hKey, RequestedInformation, pSecurityDescriptor, lpcbSecurityDescriptor)
# hKey : HKEY -> "void*"
# RequestedInformation : DWORD -> "dword"
# pSecurityDescriptor : PSECURITY_DESCRIPTOR out -> "void*"
# lpcbSecurityDescriptor : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。