Win32 API 日本語リファレンス
ホームSecurity › GetSecurityDescriptorControl

GetSecurityDescriptorControl

関数
セキュリティ記述子の制御フラグと改訂を取得する。
DLLADVAPI32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL GetSecurityDescriptorControl(
    PSECURITY_DESCRIPTOR pSecurityDescriptor,
    WORD* pControl,
    DWORD* lpdwRevision
);

パラメーター

名前方向
pSecurityDescriptorPSECURITY_DESCRIPTORin
pControlWORD*out
lpdwRevisionDWORD*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetSecurityDescriptorControl(
    PSECURITY_DESCRIPTOR pSecurityDescriptor,
    WORD* pControl,
    DWORD* lpdwRevision
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetSecurityDescriptorControl(
    IntPtr pSecurityDescriptor,   // PSECURITY_DESCRIPTOR
    out ushort pControl,   // WORD* out
    out uint lpdwRevision   // DWORD* out
);
<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetSecurityDescriptorControl(
    pSecurityDescriptor As IntPtr,   ' PSECURITY_DESCRIPTOR
    <Out> ByRef pControl As UShort,   ' WORD* out
    <Out> ByRef lpdwRevision As UInteger   ' DWORD* out
) As Boolean
End Function
' pSecurityDescriptor : PSECURITY_DESCRIPTOR
' pControl : WORD* out
' lpdwRevision : DWORD* out
Declare PtrSafe Function GetSecurityDescriptorControl Lib "advapi32" ( _
    ByVal pSecurityDescriptor As LongPtr, _
    ByRef pControl As Integer, _
    ByRef lpdwRevision As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetSecurityDescriptorControl = ctypes.windll.advapi32.GetSecurityDescriptorControl
GetSecurityDescriptorControl.restype = wintypes.BOOL
GetSecurityDescriptorControl.argtypes = [
    wintypes.HANDLE,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR
    ctypes.POINTER(ctypes.c_ushort),  # pControl : WORD* out
    ctypes.POINTER(wintypes.DWORD),  # lpdwRevision : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procGetSecurityDescriptorControl = advapi32.NewProc("GetSecurityDescriptorControl")
)

// pSecurityDescriptor (PSECURITY_DESCRIPTOR), pControl (WORD* out), lpdwRevision (DWORD* out)
r1, _, err := procGetSecurityDescriptorControl.Call(
	uintptr(pSecurityDescriptor),
	uintptr(pControl),
	uintptr(lpdwRevision),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetSecurityDescriptorControl(
  pSecurityDescriptor: THandle;   // PSECURITY_DESCRIPTOR
  pControl: Pointer;   // WORD* out
  lpdwRevision: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'GetSecurityDescriptorControl';
result := DllCall("ADVAPI32\GetSecurityDescriptorControl"
    , "Ptr", pSecurityDescriptor   ; PSECURITY_DESCRIPTOR
    , "Ptr", pControl   ; WORD* out
    , "Ptr", lpdwRevision   ; DWORD* out
    , "Int")   ; return: BOOL
●GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision) = DLL("ADVAPI32.dll", "bool GetSecurityDescriptorControl(void*, void*, void*)")
# 呼び出し: GetSecurityDescriptorControl(pSecurityDescriptor, pControl, lpdwRevision)
# pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "void*"
# pControl : WORD* out -> "void*"
# lpdwRevision : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。