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

BuildTrusteeWithSidA

関数
SIDを指定してTRUSTEE構造体を初期化する。
DLLADVAPI32.dll文字セットANSI (-A)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

void BuildTrusteeWithSidA(
    TRUSTEE_A* pTrustee,
    PSID pSid   // optional
);

パラメーター

名前方向
pTrusteeTRUSTEE_A*inout
pSidPSIDinoptional

戻り値の型: void

各言語での呼び出し定義

// ADVAPI32.dll  (ANSI / -A)
#include <windows.h>

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

BuildTrusteeWithSidA = ctypes.windll.advapi32.BuildTrusteeWithSidA
BuildTrusteeWithSidA.restype = None
BuildTrusteeWithSidA.argtypes = [
    ctypes.c_void_p,  # pTrustee : TRUSTEE_A* in/out
    wintypes.HANDLE,  # pSid : PSID optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
BuildTrusteeWithSidA = Fiddle::Function.new(
  lib['BuildTrusteeWithSidA'],
  [
    Fiddle::TYPE_VOIDP,  # pTrustee : TRUSTEE_A* in/out
    Fiddle::TYPE_VOIDP,  # pSid : PSID optional
  ],
  Fiddle::TYPE_VOID)
#[link(name = "advapi32")]
extern "system" {
    fn BuildTrusteeWithSidA(
        pTrustee: *mut TRUSTEE_A,  // TRUSTEE_A* in/out
        pSid: *mut core::ffi::c_void  // PSID optional
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi)]
public static extern void BuildTrusteeWithSidA(IntPtr pTrustee, IntPtr pSid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_BuildTrusteeWithSidA' -Namespace Win32 -PassThru
# $api::BuildTrusteeWithSidA(pTrustee, pSid)
#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" sptr, sptr
; BuildTrusteeWithSidA varptr(pTrustee), pSid
; pTrustee : TRUSTEE_A* in/out -> "sptr"
; pSid : PSID optional -> "sptr"
出力引数:
#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" var, sptr
; BuildTrusteeWithSidA pTrustee, pSid
; pTrustee : TRUSTEE_A* in/out -> "var"
; pSid : PSID optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void BuildTrusteeWithSidA(TRUSTEE_A* pTrustee, PSID pSid)
#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithSidA "BuildTrusteeWithSidA" var, intptr
; BuildTrusteeWithSidA pTrustee, pSid
; pTrustee : TRUSTEE_A* in/out -> "var"
; pSid : PSID optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procBuildTrusteeWithSidA = advapi32.NewProc("BuildTrusteeWithSidA")
)

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