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

GetSecurityDescriptorLength

関数
セキュリティ記述子のバイト長を取得する。
DLLADVAPI32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD GetSecurityDescriptorLength(
    PSECURITY_DESCRIPTOR pSecurityDescriptor
);

パラメーター

名前方向
pSecurityDescriptorPSECURITY_DESCRIPTORin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetSecurityDescriptorLength(
    PSECURITY_DESCRIPTOR pSecurityDescriptor
);
[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern uint GetSecurityDescriptorLength(
    IntPtr pSecurityDescriptor   // PSECURITY_DESCRIPTOR
);
<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function GetSecurityDescriptorLength(
    pSecurityDescriptor As IntPtr   ' PSECURITY_DESCRIPTOR
) As UInteger
End Function
' pSecurityDescriptor : PSECURITY_DESCRIPTOR
Declare PtrSafe Function GetSecurityDescriptorLength Lib "advapi32" ( _
    ByVal pSecurityDescriptor As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetSecurityDescriptorLength = ctypes.windll.advapi32.GetSecurityDescriptorLength
GetSecurityDescriptorLength.restype = wintypes.DWORD
GetSecurityDescriptorLength.argtypes = [
    wintypes.HANDLE,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
GetSecurityDescriptorLength = Fiddle::Function.new(
  lib['GetSecurityDescriptorLength'],
  [
    Fiddle::TYPE_VOIDP,  # pSecurityDescriptor : PSECURITY_DESCRIPTOR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn GetSecurityDescriptorLength(
        pSecurityDescriptor: *mut core::ffi::c_void  // PSECURITY_DESCRIPTOR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern uint GetSecurityDescriptorLength(IntPtr pSecurityDescriptor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_GetSecurityDescriptorLength' -Namespace Win32 -PassThru
# $api::GetSecurityDescriptorLength(pSecurityDescriptor)
#uselib "ADVAPI32.dll"
#func global GetSecurityDescriptorLength "GetSecurityDescriptorLength" sptr
; GetSecurityDescriptorLength pSecurityDescriptor   ; 戻り値は stat
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global GetSecurityDescriptorLength "GetSecurityDescriptorLength" sptr
; res = GetSecurityDescriptorLength(pSecurityDescriptor)
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "sptr"
; DWORD GetSecurityDescriptorLength(PSECURITY_DESCRIPTOR pSecurityDescriptor)
#uselib "ADVAPI32.dll"
#cfunc global GetSecurityDescriptorLength "GetSecurityDescriptorLength" intptr
; res = GetSecurityDescriptorLength(pSecurityDescriptor)
; pSecurityDescriptor : PSECURITY_DESCRIPTOR -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procGetSecurityDescriptorLength = advapi32.NewProc("GetSecurityDescriptorLength")
)

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