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

BuildImpersonateTrusteeW

関数
代理トラスティを設定してTRUSTEE構造体を初期化する。
DLLADVAPI32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

void BuildImpersonateTrusteeW(
    TRUSTEE_W* pTrustee,
    TRUSTEE_W* pImpersonateTrustee   // optional
);

パラメーター

名前方向
pTrusteeTRUSTEE_W*inout
pImpersonateTrusteeTRUSTEE_W*inoptional

戻り値の型: void

各言語での呼び出し定義

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

void BuildImpersonateTrusteeW(
    TRUSTEE_W* pTrustee,
    TRUSTEE_W* pImpersonateTrustee   // optional
);
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern void BuildImpersonateTrusteeW(
    IntPtr pTrustee,   // TRUSTEE_W* in/out
    IntPtr pImpersonateTrustee   // TRUSTEE_W* optional
);
<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Sub BuildImpersonateTrusteeW(
    pTrustee As IntPtr,   ' TRUSTEE_W* in/out
    pImpersonateTrustee As IntPtr   ' TRUSTEE_W* optional
)
End Sub
' pTrustee : TRUSTEE_W* in/out
' pImpersonateTrustee : TRUSTEE_W* optional
Declare PtrSafe Sub BuildImpersonateTrusteeW Lib "advapi32" ( _
    ByVal pTrustee As LongPtr, _
    ByVal pImpersonateTrustee 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

BuildImpersonateTrusteeW = ctypes.windll.advapi32.BuildImpersonateTrusteeW
BuildImpersonateTrusteeW.restype = None
BuildImpersonateTrusteeW.argtypes = [
    ctypes.c_void_p,  # pTrustee : TRUSTEE_W* in/out
    ctypes.c_void_p,  # pImpersonateTrustee : TRUSTEE_W* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
BuildImpersonateTrusteeW = Fiddle::Function.new(
  lib['BuildImpersonateTrusteeW'],
  [
    Fiddle::TYPE_VOIDP,  # pTrustee : TRUSTEE_W* in/out
    Fiddle::TYPE_VOIDP,  # pImpersonateTrustee : TRUSTEE_W* optional
  ],
  Fiddle::TYPE_VOID)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "advapi32")]
extern "system" {
    fn BuildImpersonateTrusteeW(
        pTrustee: *mut TRUSTEE_W,  // TRUSTEE_W* in/out
        pImpersonateTrustee: *mut TRUSTEE_W  // TRUSTEE_W* optional
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode)]
public static extern void BuildImpersonateTrusteeW(IntPtr pTrustee, IntPtr pImpersonateTrustee);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_BuildImpersonateTrusteeW' -Namespace Win32 -PassThru
# $api::BuildImpersonateTrusteeW(pTrustee, pImpersonateTrustee)
#uselib "ADVAPI32.dll"
#func global BuildImpersonateTrusteeW "BuildImpersonateTrusteeW" wptr, wptr
; BuildImpersonateTrusteeW varptr(pTrustee), varptr(pImpersonateTrustee)
; pTrustee : TRUSTEE_W* in/out -> "wptr"
; pImpersonateTrustee : TRUSTEE_W* optional -> "wptr"
出力引数:
#uselib "ADVAPI32.dll"
#func global BuildImpersonateTrusteeW "BuildImpersonateTrusteeW" var, var
; BuildImpersonateTrusteeW pTrustee, pImpersonateTrustee
; pTrustee : TRUSTEE_W* in/out -> "var"
; pImpersonateTrustee : TRUSTEE_W* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void BuildImpersonateTrusteeW(TRUSTEE_W* pTrustee, TRUSTEE_W* pImpersonateTrustee)
#uselib "ADVAPI32.dll"
#func global BuildImpersonateTrusteeW "BuildImpersonateTrusteeW" var, var
; BuildImpersonateTrusteeW pTrustee, pImpersonateTrustee
; pTrustee : TRUSTEE_W* in/out -> "var"
; pImpersonateTrustee : TRUSTEE_W* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procBuildImpersonateTrusteeW = advapi32.NewProc("BuildImpersonateTrusteeW")
)

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