Win32 API 日本語リファレンス
ホームSecurity.Authentication.Identity › SecAllocateAndSetCallTarget

SecAllocateAndSetCallTarget

関数
呼び出しコンテキストにIPアドレスとターゲット名を設定する。
DLLSspiCli.dll呼出規約winapi

シグネチャ

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

HRESULT SecAllocateAndSetCallTarget(
    BYTE* lpIpAddress,   // optional
    DWORD cchIpAddress,
    LPWSTR TargetName,   // optional
    INT* FreeCallContext
);

パラメーター

名前方向
lpIpAddressBYTE*inoptional
cchIpAddressDWORDin
TargetNameLPWSTRinoptional
FreeCallContextINT*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT SecAllocateAndSetCallTarget(
    BYTE* lpIpAddress,   // optional
    DWORD cchIpAddress,
    LPWSTR TargetName,   // optional
    INT* FreeCallContext
);
[DllImport("SspiCli.dll", ExactSpelling = true)]
static extern int SecAllocateAndSetCallTarget(
    IntPtr lpIpAddress,   // BYTE* optional
    uint cchIpAddress,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string TargetName,   // LPWSTR optional
    out int FreeCallContext   // INT* out
);
<DllImport("SspiCli.dll", ExactSpelling:=True)>
Public Shared Function SecAllocateAndSetCallTarget(
    lpIpAddress As IntPtr,   ' BYTE* optional
    cchIpAddress As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> TargetName As String,   ' LPWSTR optional
    <Out> ByRef FreeCallContext As Integer   ' INT* out
) As Integer
End Function
' lpIpAddress : BYTE* optional
' cchIpAddress : DWORD
' TargetName : LPWSTR optional
' FreeCallContext : INT* out
Declare PtrSafe Function SecAllocateAndSetCallTarget Lib "sspicli" ( _
    ByVal lpIpAddress As LongPtr, _
    ByVal cchIpAddress As Long, _
    ByVal TargetName As LongPtr, _
    ByRef FreeCallContext As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SecAllocateAndSetCallTarget = ctypes.windll.sspicli.SecAllocateAndSetCallTarget
SecAllocateAndSetCallTarget.restype = ctypes.c_int
SecAllocateAndSetCallTarget.argtypes = [
    ctypes.POINTER(ctypes.c_ubyte),  # lpIpAddress : BYTE* optional
    wintypes.DWORD,  # cchIpAddress : DWORD
    wintypes.LPCWSTR,  # TargetName : LPWSTR optional
    ctypes.POINTER(ctypes.c_int),  # FreeCallContext : INT* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SspiCli.dll')
SecAllocateAndSetCallTarget = Fiddle::Function.new(
  lib['SecAllocateAndSetCallTarget'],
  [
    Fiddle::TYPE_VOIDP,  # lpIpAddress : BYTE* optional
    -Fiddle::TYPE_INT,  # cchIpAddress : DWORD
    Fiddle::TYPE_VOIDP,  # TargetName : LPWSTR optional
    Fiddle::TYPE_VOIDP,  # FreeCallContext : INT* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "sspicli")]
extern "system" {
    fn SecAllocateAndSetCallTarget(
        lpIpAddress: *mut u8,  // BYTE* optional
        cchIpAddress: u32,  // DWORD
        TargetName: *mut u16,  // LPWSTR optional
        FreeCallContext: *mut i32  // INT* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SspiCli.dll")]
public static extern int SecAllocateAndSetCallTarget(IntPtr lpIpAddress, uint cchIpAddress, [MarshalAs(UnmanagedType.LPWStr)] string TargetName, out int FreeCallContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SspiCli_SecAllocateAndSetCallTarget' -Namespace Win32 -PassThru
# $api::SecAllocateAndSetCallTarget(lpIpAddress, cchIpAddress, TargetName, FreeCallContext)
#uselib "SspiCli.dll"
#func global SecAllocateAndSetCallTarget "SecAllocateAndSetCallTarget" sptr, sptr, sptr, sptr
; SecAllocateAndSetCallTarget varptr(lpIpAddress), cchIpAddress, TargetName, varptr(FreeCallContext)   ; 戻り値は stat
; lpIpAddress : BYTE* optional -> "sptr"
; cchIpAddress : DWORD -> "sptr"
; TargetName : LPWSTR optional -> "sptr"
; FreeCallContext : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SspiCli.dll"
#cfunc global SecAllocateAndSetCallTarget "SecAllocateAndSetCallTarget" var, int, wstr, var
; res = SecAllocateAndSetCallTarget(lpIpAddress, cchIpAddress, TargetName, FreeCallContext)
; lpIpAddress : BYTE* optional -> "var"
; cchIpAddress : DWORD -> "int"
; TargetName : LPWSTR optional -> "wstr"
; FreeCallContext : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SecAllocateAndSetCallTarget(BYTE* lpIpAddress, DWORD cchIpAddress, LPWSTR TargetName, INT* FreeCallContext)
#uselib "SspiCli.dll"
#cfunc global SecAllocateAndSetCallTarget "SecAllocateAndSetCallTarget" var, int, wstr, var
; res = SecAllocateAndSetCallTarget(lpIpAddress, cchIpAddress, TargetName, FreeCallContext)
; lpIpAddress : BYTE* optional -> "var"
; cchIpAddress : DWORD -> "int"
; TargetName : LPWSTR optional -> "wstr"
; FreeCallContext : INT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	sspicli = windows.NewLazySystemDLL("SspiCli.dll")
	procSecAllocateAndSetCallTarget = sspicli.NewProc("SecAllocateAndSetCallTarget")
)

// lpIpAddress (BYTE* optional), cchIpAddress (DWORD), TargetName (LPWSTR optional), FreeCallContext (INT* out)
r1, _, err := procSecAllocateAndSetCallTarget.Call(
	uintptr(lpIpAddress),
	uintptr(cchIpAddress),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(TargetName))),
	uintptr(FreeCallContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SecAllocateAndSetCallTarget(
  lpIpAddress: Pointer;   // BYTE* optional
  cchIpAddress: DWORD;   // DWORD
  TargetName: PWideChar;   // LPWSTR optional
  FreeCallContext: Pointer   // INT* out
): Integer; stdcall;
  external 'SspiCli.dll' name 'SecAllocateAndSetCallTarget';
result := DllCall("SspiCli\SecAllocateAndSetCallTarget"
    , "Ptr", lpIpAddress   ; BYTE* optional
    , "UInt", cchIpAddress   ; DWORD
    , "WStr", TargetName   ; LPWSTR optional
    , "Ptr", FreeCallContext   ; INT* out
    , "Int")   ; return: HRESULT
●SecAllocateAndSetCallTarget(lpIpAddress, cchIpAddress, TargetName, FreeCallContext) = DLL("SspiCli.dll", "int SecAllocateAndSetCallTarget(void*, dword, char*, void*)")
# 呼び出し: SecAllocateAndSetCallTarget(lpIpAddress, cchIpAddress, TargetName, FreeCallContext)
# lpIpAddress : BYTE* optional -> "void*"
# cchIpAddress : DWORD -> "dword"
# TargetName : LPWSTR optional -> "char*"
# FreeCallContext : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。