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

SspiPromptForCredentialsW

関数
資格情報入力用のダイアログを表示してユーザーから認証情報を取得する(Unicode版)。
DLLcredui.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

DWORD SspiPromptForCredentialsW(
    LPCWSTR pszTargetName,
    void* pUiInfo,   // optional
    DWORD dwAuthError,
    LPCWSTR pszPackage,
    void* pInputAuthIdentity,   // optional
    void** ppAuthIdentity,
    INT* pfSave,   // optional
    DWORD dwFlags
);

パラメーター

名前方向
pszTargetNameLPCWSTRin
pUiInfovoid*inoptional
dwAuthErrorDWORDin
pszPackageLPCWSTRin
pInputAuthIdentityvoid*inoptional
ppAuthIdentityvoid**out
pfSaveINT*inoutoptional
dwFlagsDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD SspiPromptForCredentialsW(
    LPCWSTR pszTargetName,
    void* pUiInfo,   // optional
    DWORD dwAuthError,
    LPCWSTR pszPackage,
    void* pInputAuthIdentity,   // optional
    void** ppAuthIdentity,
    INT* pfSave,   // optional
    DWORD dwFlags
);
[DllImport("credui.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint SspiPromptForCredentialsW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszTargetName,   // LPCWSTR
    IntPtr pUiInfo,   // void* optional
    uint dwAuthError,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszPackage,   // LPCWSTR
    IntPtr pInputAuthIdentity,   // void* optional
    IntPtr ppAuthIdentity,   // void** out
    IntPtr pfSave,   // INT* optional, in/out
    uint dwFlags   // DWORD
);
<DllImport("credui.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SspiPromptForCredentialsW(
    <MarshalAs(UnmanagedType.LPWStr)> pszTargetName As String,   ' LPCWSTR
    pUiInfo As IntPtr,   ' void* optional
    dwAuthError As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszPackage As String,   ' LPCWSTR
    pInputAuthIdentity As IntPtr,   ' void* optional
    ppAuthIdentity As IntPtr,   ' void** out
    pfSave As IntPtr,   ' INT* optional, in/out
    dwFlags As UInteger   ' DWORD
) As UInteger
End Function
' pszTargetName : LPCWSTR
' pUiInfo : void* optional
' dwAuthError : DWORD
' pszPackage : LPCWSTR
' pInputAuthIdentity : void* optional
' ppAuthIdentity : void** out
' pfSave : INT* optional, in/out
' dwFlags : DWORD
Declare PtrSafe Function SspiPromptForCredentialsW Lib "credui" ( _
    ByVal pszTargetName As LongPtr, _
    ByVal pUiInfo As LongPtr, _
    ByVal dwAuthError As Long, _
    ByVal pszPackage As LongPtr, _
    ByVal pInputAuthIdentity As LongPtr, _
    ByVal ppAuthIdentity As LongPtr, _
    ByVal pfSave As LongPtr, _
    ByVal dwFlags As Long) As Long
' 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

SspiPromptForCredentialsW = ctypes.windll.credui.SspiPromptForCredentialsW
SspiPromptForCredentialsW.restype = wintypes.DWORD
SspiPromptForCredentialsW.argtypes = [
    wintypes.LPCWSTR,  # pszTargetName : LPCWSTR
    ctypes.POINTER(None),  # pUiInfo : void* optional
    wintypes.DWORD,  # dwAuthError : DWORD
    wintypes.LPCWSTR,  # pszPackage : LPCWSTR
    ctypes.POINTER(None),  # pInputAuthIdentity : void* optional
    ctypes.c_void_p,  # ppAuthIdentity : void** out
    ctypes.POINTER(ctypes.c_int),  # pfSave : INT* optional, in/out
    wintypes.DWORD,  # dwFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('credui.dll')
SspiPromptForCredentialsW = Fiddle::Function.new(
  lib['SspiPromptForCredentialsW'],
  [
    Fiddle::TYPE_VOIDP,  # pszTargetName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pUiInfo : void* optional
    -Fiddle::TYPE_INT,  # dwAuthError : DWORD
    Fiddle::TYPE_VOIDP,  # pszPackage : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pInputAuthIdentity : void* optional
    Fiddle::TYPE_VOIDP,  # ppAuthIdentity : void** out
    Fiddle::TYPE_VOIDP,  # pfSave : INT* optional, in/out
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "credui")]
extern "system" {
    fn SspiPromptForCredentialsW(
        pszTargetName: *const u16,  // LPCWSTR
        pUiInfo: *mut (),  // void* optional
        dwAuthError: u32,  // DWORD
        pszPackage: *const u16,  // LPCWSTR
        pInputAuthIdentity: *mut (),  // void* optional
        ppAuthIdentity: *mut *mut (),  // void** out
        pfSave: *mut i32,  // INT* optional, in/out
        dwFlags: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("credui.dll", CharSet = CharSet.Unicode)]
public static extern uint SspiPromptForCredentialsW([MarshalAs(UnmanagedType.LPWStr)] string pszTargetName, IntPtr pUiInfo, uint dwAuthError, [MarshalAs(UnmanagedType.LPWStr)] string pszPackage, IntPtr pInputAuthIdentity, IntPtr ppAuthIdentity, IntPtr pfSave, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'credui_SspiPromptForCredentialsW' -Namespace Win32 -PassThru
# $api::SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
#uselib "credui.dll"
#func global SspiPromptForCredentialsW "SspiPromptForCredentialsW" wptr, wptr, wptr, wptr, wptr, wptr, wptr, wptr
; SspiPromptForCredentialsW pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, varptr(pfSave), dwFlags   ; 戻り値は stat
; pszTargetName : LPCWSTR -> "wptr"
; pUiInfo : void* optional -> "wptr"
; dwAuthError : DWORD -> "wptr"
; pszPackage : LPCWSTR -> "wptr"
; pInputAuthIdentity : void* optional -> "wptr"
; ppAuthIdentity : void** out -> "wptr"
; pfSave : INT* optional, in/out -> "wptr"
; dwFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "credui.dll"
#cfunc global SspiPromptForCredentialsW "SspiPromptForCredentialsW" wstr, sptr, int, wstr, sptr, sptr, var, int
; res = SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
; pszTargetName : LPCWSTR -> "wstr"
; pUiInfo : void* optional -> "sptr"
; dwAuthError : DWORD -> "int"
; pszPackage : LPCWSTR -> "wstr"
; pInputAuthIdentity : void* optional -> "sptr"
; ppAuthIdentity : void** out -> "sptr"
; pfSave : INT* optional, in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD SspiPromptForCredentialsW(LPCWSTR pszTargetName, void* pUiInfo, DWORD dwAuthError, LPCWSTR pszPackage, void* pInputAuthIdentity, void** ppAuthIdentity, INT* pfSave, DWORD dwFlags)
#uselib "credui.dll"
#cfunc global SspiPromptForCredentialsW "SspiPromptForCredentialsW" wstr, intptr, int, wstr, intptr, intptr, var, int
; res = SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
; pszTargetName : LPCWSTR -> "wstr"
; pUiInfo : void* optional -> "intptr"
; dwAuthError : DWORD -> "int"
; pszPackage : LPCWSTR -> "wstr"
; pInputAuthIdentity : void* optional -> "intptr"
; ppAuthIdentity : void** out -> "intptr"
; pfSave : INT* optional, in/out -> "var"
; dwFlags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	credui = windows.NewLazySystemDLL("credui.dll")
	procSspiPromptForCredentialsW = credui.NewProc("SspiPromptForCredentialsW")
)

// pszTargetName (LPCWSTR), pUiInfo (void* optional), dwAuthError (DWORD), pszPackage (LPCWSTR), pInputAuthIdentity (void* optional), ppAuthIdentity (void** out), pfSave (INT* optional, in/out), dwFlags (DWORD)
r1, _, err := procSspiPromptForCredentialsW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszTargetName))),
	uintptr(pUiInfo),
	uintptr(dwAuthError),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPackage))),
	uintptr(pInputAuthIdentity),
	uintptr(ppAuthIdentity),
	uintptr(pfSave),
	uintptr(dwFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SspiPromptForCredentialsW(
  pszTargetName: PWideChar;   // LPCWSTR
  pUiInfo: Pointer;   // void* optional
  dwAuthError: DWORD;   // DWORD
  pszPackage: PWideChar;   // LPCWSTR
  pInputAuthIdentity: Pointer;   // void* optional
  ppAuthIdentity: Pointer;   // void** out
  pfSave: Pointer;   // INT* optional, in/out
  dwFlags: DWORD   // DWORD
): DWORD; stdcall;
  external 'credui.dll' name 'SspiPromptForCredentialsW';
result := DllCall("credui\SspiPromptForCredentialsW"
    , "WStr", pszTargetName   ; LPCWSTR
    , "Ptr", pUiInfo   ; void* optional
    , "UInt", dwAuthError   ; DWORD
    , "WStr", pszPackage   ; LPCWSTR
    , "Ptr", pInputAuthIdentity   ; void* optional
    , "Ptr", ppAuthIdentity   ; void** out
    , "Ptr", pfSave   ; INT* optional, in/out
    , "UInt", dwFlags   ; DWORD
    , "UInt")   ; return: DWORD
●SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags) = DLL("credui.dll", "dword SspiPromptForCredentialsW(char*, void*, dword, char*, void*, void*, void*, dword)")
# 呼び出し: SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
# pszTargetName : LPCWSTR -> "char*"
# pUiInfo : void* optional -> "void*"
# dwAuthError : DWORD -> "dword"
# pszPackage : LPCWSTR -> "char*"
# pInputAuthIdentity : void* optional -> "void*"
# ppAuthIdentity : void** out -> "void*"
# pfSave : INT* optional, in/out -> "void*"
# dwFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。