ホーム › Security.Authentication.Identity › SspiPromptForCredentialsW
SspiPromptForCredentialsW
関数資格情報入力用のダイアログを表示してユーザーから認証情報を取得する(Unicode版)。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszTargetName | LPCWSTR | in | 資格情報を要求する対象のターゲット名を示すワイド文字列。 |
| pUiInfo | void* | inoptional | 資格情報入力UIの外観を制御するCREDUI_INFOW構造体へのポインタ。NULL可。 |
| dwAuthError | DWORD | in | 前回の認証で発生したWin32エラーコード。UIにエラー表示するために使用する。 |
| pszPackage | LPCWSTR | in | 資格情報の対象となるセキュリティパッケージ名を示すワイド文字列。 |
| pInputAuthIdentity | void* | inoptional | 事前入力する既存の認証ID(SEC_WINNT_AUTH_IDENTITY_OPAQUE)へのポインタ。NULL可。 |
| ppAuthIdentity | void** | out | 出力。ユーザーが入力した認証ID構造体を受け取るポインタ。SspiFreeAuthIdentityで解放する。 |
| pfSave | INT* | inoutoptional | 入出力。資格情報の保存チェックボックス状態を受け渡すINTへのポインタ。 |
| dwFlags | DWORD | in | UIの動作を制御するフラグ(CREDUIWIN_GENERIC等)。 |
戻り値の型: 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 方式にも切替可。#uselib "credui.dll" #cfunc global SspiPromptForCredentialsW "SspiPromptForCredentialsW" wstr, sptr, int, wstr, sptr, sptr, sptr, int ; res = SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, varptr(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 -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, int ; res = SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, varptr(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 -> "intptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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 版の利用を推奨。const std = @import("std");
extern "credui" fn SspiPromptForCredentialsW(
pszTargetName: [*c]const u16, // LPCWSTR
pUiInfo: ?*anyopaque, // void* optional
dwAuthError: u32, // DWORD
pszPackage: [*c]const u16, // LPCWSTR
pInputAuthIdentity: ?*anyopaque, // void* optional
ppAuthIdentity: ?*anyopaque, // void** out
pfSave: [*c]i32, // INT* optional, in/out
dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc SspiPromptForCredentialsW(
pszTargetName: WideCString, # LPCWSTR
pUiInfo: pointer, # void* optional
dwAuthError: uint32, # DWORD
pszPackage: WideCString, # LPCWSTR
pInputAuthIdentity: pointer, # void* optional
ppAuthIdentity: pointer, # void** out
pfSave: ptr int32, # INT* optional, in/out
dwFlags: uint32 # DWORD
): uint32 {.importc: "SspiPromptForCredentialsW", stdcall, dynlib: "credui.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "credui");
extern(Windows)
uint SspiPromptForCredentialsW(
const(wchar)* pszTargetName, // LPCWSTR
void* pUiInfo, // void* optional
uint dwAuthError, // DWORD
const(wchar)* pszPackage, // LPCWSTR
void* pInputAuthIdentity, // void* optional
void** ppAuthIdentity, // void** out
int* pfSave, // INT* optional, in/out
uint dwFlags // DWORD
);ccall((:SspiPromptForCredentialsW, "credui.dll"), stdcall, UInt32,
(Cwstring, Ptr{Cvoid}, UInt32, Cwstring, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Int32}, UInt32),
pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
# pszTargetName : LPCWSTR -> Cwstring
# pUiInfo : void* optional -> Ptr{Cvoid}
# dwAuthError : DWORD -> UInt32
# pszPackage : LPCWSTR -> Cwstring
# pInputAuthIdentity : void* optional -> Ptr{Cvoid}
# ppAuthIdentity : void** out -> Ptr{Cvoid}
# pfSave : INT* optional, in/out -> Ptr{Int32}
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t SspiPromptForCredentialsW(
const uint16_t* pszTargetName,
void* pUiInfo,
uint32_t dwAuthError,
const uint16_t* pszPackage,
void* pInputAuthIdentity,
void** ppAuthIdentity,
int32_t* pfSave,
uint32_t dwFlags);
]]
local credui = ffi.load("credui")
-- credui.SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
-- pszTargetName : LPCWSTR
-- pUiInfo : void* optional
-- dwAuthError : DWORD
-- pszPackage : LPCWSTR
-- pInputAuthIdentity : void* optional
-- ppAuthIdentity : void** out
-- pfSave : INT* optional, in/out
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('credui.dll');
const SspiPromptForCredentialsW = lib.func('__stdcall', 'SspiPromptForCredentialsW', 'uint32_t', ['str16', 'void *', 'uint32_t', 'str16', 'void *', 'void *', 'int32_t *', 'uint32_t']);
// SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
// pszTargetName : LPCWSTR -> 'str16'
// pUiInfo : void* optional -> 'void *'
// dwAuthError : DWORD -> 'uint32_t'
// pszPackage : LPCWSTR -> 'str16'
// pInputAuthIdentity : void* optional -> 'void *'
// ppAuthIdentity : void** out -> 'void *'
// pfSave : INT* optional, in/out -> 'int32_t *'
// dwFlags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("credui.dll", {
SspiPromptForCredentialsW: { parameters: ["buffer", "pointer", "u32", "buffer", "pointer", "pointer", "pointer", "u32"], result: "u32" },
});
// lib.symbols.SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
// pszTargetName : LPCWSTR -> "buffer"
// pUiInfo : void* optional -> "pointer"
// dwAuthError : DWORD -> "u32"
// pszPackage : LPCWSTR -> "buffer"
// pInputAuthIdentity : void* optional -> "pointer"
// ppAuthIdentity : void** out -> "pointer"
// pfSave : INT* optional, in/out -> "pointer"
// dwFlags : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SspiPromptForCredentialsW(
const uint16_t* pszTargetName,
void* pUiInfo,
uint32_t dwAuthError,
const uint16_t* pszPackage,
void* pInputAuthIdentity,
void** ppAuthIdentity,
int32_t* pfSave,
uint32_t dwFlags);
C, "credui.dll");
// $ffi->SspiPromptForCredentialsW(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags);
// pszTargetName : LPCWSTR
// pUiInfo : void* optional
// dwAuthError : DWORD
// pszPackage : LPCWSTR
// pInputAuthIdentity : void* optional
// ppAuthIdentity : void** out
// pfSave : INT* optional, in/out
// dwFlags : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Credui extends StdCallLibrary {
Credui INSTANCE = Native.load("credui", Credui.class, W32APIOptions.UNICODE_OPTIONS);
int SspiPromptForCredentialsW(
WString pszTargetName, // LPCWSTR
Pointer pUiInfo, // void* optional
int dwAuthError, // DWORD
WString pszPackage, // LPCWSTR
Pointer pInputAuthIdentity, // void* optional
Pointer ppAuthIdentity, // void** out
IntByReference pfSave, // INT* optional, in/out
int dwFlags // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("credui")]
lib Libcredui
fun SspiPromptForCredentialsW = SspiPromptForCredentialsW(
pszTargetName : UInt16*, # LPCWSTR
pUiInfo : Void*, # void* optional
dwAuthError : UInt32, # DWORD
pszPackage : UInt16*, # LPCWSTR
pInputAuthIdentity : Void*, # void* optional
ppAuthIdentity : Void**, # void** out
pfSave : Int32*, # INT* optional, in/out
dwFlags : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SspiPromptForCredentialsWNative = Uint32 Function(Pointer<Utf16>, Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Int32>, Uint32);
typedef SspiPromptForCredentialsWDart = int Function(Pointer<Utf16>, Pointer<Void>, int, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Int32>, int);
final SspiPromptForCredentialsW = DynamicLibrary.open('credui.dll')
.lookupFunction<SspiPromptForCredentialsWNative, SspiPromptForCredentialsWDart>('SspiPromptForCredentialsW');
// pszTargetName : LPCWSTR -> Pointer<Utf16>
// pUiInfo : void* optional -> Pointer<Void>
// dwAuthError : DWORD -> Uint32
// pszPackage : LPCWSTR -> Pointer<Utf16>
// pInputAuthIdentity : void* optional -> Pointer<Void>
// ppAuthIdentity : void** out -> Pointer<Void>
// pfSave : INT* optional, in/out -> Pointer<Int32>
// dwFlags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SspiPromptForCredentialsW"
c_SspiPromptForCredentialsW :: CWString -> Ptr () -> Word32 -> CWString -> Ptr () -> Ptr () -> Ptr Int32 -> Word32 -> IO Word32
-- pszTargetName : LPCWSTR -> CWString
-- pUiInfo : void* optional -> Ptr ()
-- dwAuthError : DWORD -> Word32
-- pszPackage : LPCWSTR -> CWString
-- pInputAuthIdentity : void* optional -> Ptr ()
-- ppAuthIdentity : void** out -> Ptr ()
-- pfSave : INT* optional, in/out -> Ptr Int32
-- dwFlags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let sspipromptforcredentialsw =
foreign "SspiPromptForCredentialsW"
((ptr uint16_t) @-> (ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr int32_t) @-> uint32_t @-> returning uint32_t)
(* pszTargetName : LPCWSTR -> (ptr uint16_t) *)
(* pUiInfo : void* optional -> (ptr void) *)
(* dwAuthError : DWORD -> uint32_t *)
(* pszPackage : LPCWSTR -> (ptr uint16_t) *)
(* pInputAuthIdentity : void* optional -> (ptr void) *)
(* ppAuthIdentity : void** out -> (ptr void) *)
(* pfSave : INT* optional, in/out -> (ptr int32_t) *)
(* dwFlags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library credui (t "credui.dll"))
(cffi:use-foreign-library credui)
(cffi:defcfun ("SspiPromptForCredentialsW" sspi-prompt-for-credentials-w :convention :stdcall) :uint32
(psz-target-name (:string :encoding :utf-16le)) ; LPCWSTR
(p-ui-info :pointer) ; void* optional
(dw-auth-error :uint32) ; DWORD
(psz-package (:string :encoding :utf-16le)) ; LPCWSTR
(p-input-auth-identity :pointer) ; void* optional
(pp-auth-identity :pointer) ; void** out
(pf-save :pointer) ; INT* optional, in/out
(dw-flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SspiPromptForCredentialsW = Win32::API::More->new('credui',
'DWORD SspiPromptForCredentialsW(LPCWSTR pszTargetName, LPVOID pUiInfo, DWORD dwAuthError, LPCWSTR pszPackage, LPVOID pInputAuthIdentity, LPVOID ppAuthIdentity, LPVOID pfSave, DWORD dwFlags)');
# my $ret = $SspiPromptForCredentialsW->Call($pszTargetName, $pUiInfo, $dwAuthError, $pszPackage, $pInputAuthIdentity, $ppAuthIdentity, $pfSave, $dwFlags);
# pszTargetName : LPCWSTR -> LPCWSTR
# pUiInfo : void* optional -> LPVOID
# dwAuthError : DWORD -> DWORD
# pszPackage : LPCWSTR -> LPCWSTR
# pInputAuthIdentity : void* optional -> LPVOID
# ppAuthIdentity : void** out -> LPVOID
# pfSave : INT* optional, in/out -> LPVOID
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f SspiPromptForCredentialsA (ANSI版) — 資格情報入力用のダイアログを表示してユーザーから認証情報を取得する(ANSI版)。