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

BuildTrusteeWithSidW

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

シグネチャ

// ADVAPI32.dll  (Unicode / -W)
#include <windows.h>

void BuildTrusteeWithSidW(
    TRUSTEE_W* pTrustee,
    PSID pSid   // optional
);

パラメーター

名前方向
pTrusteeTRUSTEE_W*inout
pSidPSIDinoptional

戻り値の型: void

各言語での呼び出し定義

// ADVAPI32.dll  (Unicode / -W)
#include <windows.h>

void BuildTrusteeWithSidW(
    TRUSTEE_W* pTrustee,
    PSID pSid   // optional
);
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern void BuildTrusteeWithSidW(
    IntPtr pTrustee,   // TRUSTEE_W* in/out
    IntPtr pSid   // PSID optional
);
<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Sub BuildTrusteeWithSidW(
    pTrustee As IntPtr,   ' TRUSTEE_W* in/out
    pSid As IntPtr   ' PSID optional
)
End Sub
' pTrustee : TRUSTEE_W* in/out
' pSid : PSID optional
Declare PtrSafe Sub BuildTrusteeWithSidW Lib "advapi32" ( _
    ByVal pTrustee As LongPtr, _
    ByVal pSid As LongPtr)
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

lib = Fiddle.dlopen('ADVAPI32.dll')
BuildTrusteeWithSidW = Fiddle::Function.new(
  lib['BuildTrusteeWithSidW'],
  [
    Fiddle::TYPE_VOIDP,  # pTrustee : TRUSTEE_W* in/out
    Fiddle::TYPE_VOIDP,  # pSid : PSID optional
  ],
  Fiddle::TYPE_VOID)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "advapi32")]
extern "system" {
    fn BuildTrusteeWithSidW(
        pTrustee: *mut TRUSTEE_W,  // TRUSTEE_W* 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.Unicode)]
public static extern void BuildTrusteeWithSidW(IntPtr pTrustee, IntPtr pSid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_BuildTrusteeWithSidW' -Namespace Win32 -PassThru
# $api::BuildTrusteeWithSidW(pTrustee, pSid)
#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithSidW "BuildTrusteeWithSidW" wptr, wptr
; BuildTrusteeWithSidW varptr(pTrustee), pSid
; pTrustee : TRUSTEE_W* in/out -> "wptr"
; pSid : PSID optional -> "wptr"
出力引数:
#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithSidW "BuildTrusteeWithSidW" var, sptr
; BuildTrusteeWithSidW pTrustee, pSid
; pTrustee : TRUSTEE_W* in/out -> "var"
; pSid : PSID optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void BuildTrusteeWithSidW(TRUSTEE_W* pTrustee, PSID pSid)
#uselib "ADVAPI32.dll"
#func global BuildTrusteeWithSidW "BuildTrusteeWithSidW" var, intptr
; BuildTrusteeWithSidW pTrustee, pSid
; pTrustee : TRUSTEE_W* in/out -> "var"
; pSid : PSID optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procBuildTrusteeWithSidW = advapi32.NewProc("BuildTrusteeWithSidW")
)

// pTrustee (TRUSTEE_W* in/out), pSid (PSID optional)
r1, _, err := procBuildTrusteeWithSidW.Call(
	uintptr(pTrustee),
	uintptr(pSid),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure BuildTrusteeWithSidW(
  pTrustee: Pointer;   // TRUSTEE_W* in/out
  pSid: THandle   // PSID optional
); stdcall;
  external 'ADVAPI32.dll' name 'BuildTrusteeWithSidW';
result := DllCall("ADVAPI32\BuildTrusteeWithSidW"
    , "Ptr", pTrustee   ; TRUSTEE_W* in/out
    , "Ptr", pSid   ; PSID optional
    , "Int")   ; return: void
●BuildTrusteeWithSidW(pTrustee, pSid) = DLL("ADVAPI32.dll", "int BuildTrusteeWithSidW(void*, void*)")
# 呼び出し: BuildTrusteeWithSidW(pTrustee, pSid)
# pTrustee : TRUSTEE_W* in/out -> "void*"
# pSid : PSID optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。