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

BuildImpersonateTrusteeA

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

シグネチャ

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

void BuildImpersonateTrusteeA(
    TRUSTEE_A* pTrustee,
    TRUSTEE_A* pImpersonateTrustee   // optional
);

パラメーター

名前方向
pTrusteeTRUSTEE_A*inout
pImpersonateTrusteeTRUSTEE_A*inoptional

戻り値の型: void

各言語での呼び出し定義

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

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

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

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

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procBuildImpersonateTrusteeA = advapi32.NewProc("BuildImpersonateTrusteeA")
)

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