ホーム › Security.Authentication.Identity › SspiGetTargetHostName
SspiGetTargetHostName
関数SPNターゲット名から対象のホスト名を取得する。
シグネチャ
// SECUR32.dll
#include <windows.h>
HRESULT SspiGetTargetHostName(
LPCWSTR pszTargetName,
LPWSTR* pszHostName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszTargetName | LPCWSTR | in |
| pszHostName | LPWSTR* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// SECUR32.dll
#include <windows.h>
HRESULT SspiGetTargetHostName(
LPCWSTR pszTargetName,
LPWSTR* pszHostName
);[DllImport("SECUR32.dll", ExactSpelling = true)]
static extern int SspiGetTargetHostName(
[MarshalAs(UnmanagedType.LPWStr)] string pszTargetName, // LPCWSTR
IntPtr pszHostName // LPWSTR* out
);<DllImport("SECUR32.dll", ExactSpelling:=True)>
Public Shared Function SspiGetTargetHostName(
<MarshalAs(UnmanagedType.LPWStr)> pszTargetName As String, ' LPCWSTR
pszHostName As IntPtr ' LPWSTR* out
) As Integer
End Function' pszTargetName : LPCWSTR
' pszHostName : LPWSTR* out
Declare PtrSafe Function SspiGetTargetHostName Lib "secur32" ( _
ByVal pszTargetName As LongPtr, _
ByVal pszHostName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SspiGetTargetHostName = ctypes.windll.secur32.SspiGetTargetHostName
SspiGetTargetHostName.restype = ctypes.c_int
SspiGetTargetHostName.argtypes = [
wintypes.LPCWSTR, # pszTargetName : LPCWSTR
ctypes.c_void_p, # pszHostName : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SECUR32.dll')
SspiGetTargetHostName = Fiddle::Function.new(
lib['SspiGetTargetHostName'],
[
Fiddle::TYPE_VOIDP, # pszTargetName : LPCWSTR
Fiddle::TYPE_VOIDP, # pszHostName : LPWSTR* out
],
Fiddle::TYPE_INT)#[link(name = "secur32")]
extern "system" {
fn SspiGetTargetHostName(
pszTargetName: *const u16, // LPCWSTR
pszHostName: *mut *mut u16 // LPWSTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SECUR32.dll")]
public static extern int SspiGetTargetHostName([MarshalAs(UnmanagedType.LPWStr)] string pszTargetName, IntPtr pszHostName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SECUR32_SspiGetTargetHostName' -Namespace Win32 -PassThru
# $api::SspiGetTargetHostName(pszTargetName, pszHostName)#uselib "SECUR32.dll"
#func global SspiGetTargetHostName "SspiGetTargetHostName" sptr, sptr
; SspiGetTargetHostName pszTargetName, varptr(pszHostName) ; 戻り値は stat
; pszTargetName : LPCWSTR -> "sptr"
; pszHostName : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SECUR32.dll" #cfunc global SspiGetTargetHostName "SspiGetTargetHostName" wstr, var ; res = SspiGetTargetHostName(pszTargetName, pszHostName) ; pszTargetName : LPCWSTR -> "wstr" ; pszHostName : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SECUR32.dll" #cfunc global SspiGetTargetHostName "SspiGetTargetHostName" wstr, sptr ; res = SspiGetTargetHostName(pszTargetName, varptr(pszHostName)) ; pszTargetName : LPCWSTR -> "wstr" ; pszHostName : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SspiGetTargetHostName(LPCWSTR pszTargetName, LPWSTR* pszHostName) #uselib "SECUR32.dll" #cfunc global SspiGetTargetHostName "SspiGetTargetHostName" wstr, var ; res = SspiGetTargetHostName(pszTargetName, pszHostName) ; pszTargetName : LPCWSTR -> "wstr" ; pszHostName : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SspiGetTargetHostName(LPCWSTR pszTargetName, LPWSTR* pszHostName) #uselib "SECUR32.dll" #cfunc global SspiGetTargetHostName "SspiGetTargetHostName" wstr, intptr ; res = SspiGetTargetHostName(pszTargetName, varptr(pszHostName)) ; pszTargetName : LPCWSTR -> "wstr" ; pszHostName : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
secur32 = windows.NewLazySystemDLL("SECUR32.dll")
procSspiGetTargetHostName = secur32.NewProc("SspiGetTargetHostName")
)
// pszTargetName (LPCWSTR), pszHostName (LPWSTR* out)
r1, _, err := procSspiGetTargetHostName.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszTargetName))),
uintptr(pszHostName),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SspiGetTargetHostName(
pszTargetName: PWideChar; // LPCWSTR
pszHostName: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'SECUR32.dll' name 'SspiGetTargetHostName';result := DllCall("SECUR32\SspiGetTargetHostName"
, "WStr", pszTargetName ; LPCWSTR
, "Ptr", pszHostName ; LPWSTR* out
, "Int") ; return: HRESULT●SspiGetTargetHostName(pszTargetName, pszHostName) = DLL("SECUR32.dll", "int SspiGetTargetHostName(char*, void*)")
# 呼び出し: SspiGetTargetHostName(pszTargetName, pszHostName)
# pszTargetName : LPCWSTR -> "char*"
# pszHostName : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。