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

GetLengthSid

関数
指定SIDのバイト長を取得する。
DLLADVAPI32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD GetLengthSid(
    PSID pSid
);

パラメーター

名前方向
pSidPSIDinout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

GetLengthSid = ctypes.windll.advapi32.GetLengthSid
GetLengthSid.restype = wintypes.DWORD
GetLengthSid.argtypes = [
    wintypes.HANDLE,  # pSid : PSID in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procGetLengthSid = advapi32.NewProc("GetLengthSid")
)

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