ホーム › Security.Authentication.Identity › SspiPromptForCredentialsA
SspiPromptForCredentialsA
関数資格情報入力用のダイアログを表示してユーザーから認証情報を取得する(ANSI版)。
シグネチャ
// credui.dll (ANSI / -A)
#include <windows.h>
DWORD SspiPromptForCredentialsA(
LPCSTR pszTargetName,
void* pUiInfo, // optional
DWORD dwAuthError,
LPCSTR pszPackage,
void* pInputAuthIdentity, // optional
void** ppAuthIdentity,
INT* pfSave, // optional
DWORD dwFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszTargetName | LPCSTR | in | 資格情報を要求する対象のターゲット名を示すANSI文字列。 |
| pUiInfo | void* | inoptional | 資格情報入力UIの外観を制御するCREDUI_INFOA構造体へのポインタ。NULL可。 |
| dwAuthError | DWORD | in | 前回の認証で発生したWin32エラーコード。UIにエラー表示するために使用する。 |
| pszPackage | LPCSTR | in | 資格情報の対象となるセキュリティパッケージ名を示すANSI文字列。 |
| 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 (ANSI / -A)
#include <windows.h>
DWORD SspiPromptForCredentialsA(
LPCSTR pszTargetName,
void* pUiInfo, // optional
DWORD dwAuthError,
LPCSTR pszPackage,
void* pInputAuthIdentity, // optional
void** ppAuthIdentity,
INT* pfSave, // optional
DWORD dwFlags
);[DllImport("credui.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint SspiPromptForCredentialsA(
[MarshalAs(UnmanagedType.LPStr)] string pszTargetName, // LPCSTR
IntPtr pUiInfo, // void* optional
uint dwAuthError, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string pszPackage, // LPCSTR
IntPtr pInputAuthIdentity, // void* optional
IntPtr ppAuthIdentity, // void** out
IntPtr pfSave, // INT* optional, in/out
uint dwFlags // DWORD
);<DllImport("credui.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SspiPromptForCredentialsA(
<MarshalAs(UnmanagedType.LPStr)> pszTargetName As String, ' LPCSTR
pUiInfo As IntPtr, ' void* optional
dwAuthError As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszPackage As String, ' LPCSTR
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 : LPCSTR
' pUiInfo : void* optional
' dwAuthError : DWORD
' pszPackage : LPCSTR
' pInputAuthIdentity : void* optional
' ppAuthIdentity : void** out
' pfSave : INT* optional, in/out
' dwFlags : DWORD
Declare PtrSafe Function SspiPromptForCredentialsA Lib "credui" ( _
ByVal pszTargetName As String, _
ByVal pUiInfo As LongPtr, _
ByVal dwAuthError As Long, _
ByVal pszPackage As String, _
ByVal pInputAuthIdentity As LongPtr, _
ByVal ppAuthIdentity As LongPtr, _
ByVal pfSave As LongPtr, _
ByVal dwFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SspiPromptForCredentialsA = ctypes.windll.credui.SspiPromptForCredentialsA
SspiPromptForCredentialsA.restype = wintypes.DWORD
SspiPromptForCredentialsA.argtypes = [
wintypes.LPCSTR, # pszTargetName : LPCSTR
ctypes.POINTER(None), # pUiInfo : void* optional
wintypes.DWORD, # dwAuthError : DWORD
wintypes.LPCSTR, # pszPackage : LPCSTR
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')
SspiPromptForCredentialsA = Fiddle::Function.new(
lib['SspiPromptForCredentialsA'],
[
Fiddle::TYPE_VOIDP, # pszTargetName : LPCSTR
Fiddle::TYPE_VOIDP, # pUiInfo : void* optional
-Fiddle::TYPE_INT, # dwAuthError : DWORD
Fiddle::TYPE_VOIDP, # pszPackage : LPCSTR
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)#[link(name = "credui")]
extern "system" {
fn SspiPromptForCredentialsA(
pszTargetName: *const u8, // LPCSTR
pUiInfo: *mut (), // void* optional
dwAuthError: u32, // DWORD
pszPackage: *const u8, // LPCSTR
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.Ansi)]
public static extern uint SspiPromptForCredentialsA([MarshalAs(UnmanagedType.LPStr)] string pszTargetName, IntPtr pUiInfo, uint dwAuthError, [MarshalAs(UnmanagedType.LPStr)] string pszPackage, IntPtr pInputAuthIdentity, IntPtr ppAuthIdentity, IntPtr pfSave, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'credui_SspiPromptForCredentialsA' -Namespace Win32 -PassThru
# $api::SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)#uselib "credui.dll"
#func global SspiPromptForCredentialsA "SspiPromptForCredentialsA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; SspiPromptForCredentialsA pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, varptr(pfSave), dwFlags ; 戻り値は stat
; pszTargetName : LPCSTR -> "sptr"
; pUiInfo : void* optional -> "sptr"
; dwAuthError : DWORD -> "sptr"
; pszPackage : LPCSTR -> "sptr"
; pInputAuthIdentity : void* optional -> "sptr"
; ppAuthIdentity : void** out -> "sptr"
; pfSave : INT* optional, in/out -> "sptr"
; dwFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "credui.dll" #cfunc global SspiPromptForCredentialsA "SspiPromptForCredentialsA" str, sptr, int, str, sptr, sptr, var, int ; res = SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags) ; pszTargetName : LPCSTR -> "str" ; pUiInfo : void* optional -> "sptr" ; dwAuthError : DWORD -> "int" ; pszPackage : LPCSTR -> "str" ; pInputAuthIdentity : void* optional -> "sptr" ; ppAuthIdentity : void** out -> "sptr" ; pfSave : INT* optional, in/out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "credui.dll" #cfunc global SspiPromptForCredentialsA "SspiPromptForCredentialsA" str, sptr, int, str, sptr, sptr, sptr, int ; res = SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, varptr(pfSave), dwFlags) ; pszTargetName : LPCSTR -> "str" ; pUiInfo : void* optional -> "sptr" ; dwAuthError : DWORD -> "int" ; pszPackage : LPCSTR -> "str" ; pInputAuthIdentity : void* optional -> "sptr" ; ppAuthIdentity : void** out -> "sptr" ; pfSave : INT* optional, in/out -> "sptr" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SspiPromptForCredentialsA(LPCSTR pszTargetName, void* pUiInfo, DWORD dwAuthError, LPCSTR pszPackage, void* pInputAuthIdentity, void** ppAuthIdentity, INT* pfSave, DWORD dwFlags) #uselib "credui.dll" #cfunc global SspiPromptForCredentialsA "SspiPromptForCredentialsA" str, intptr, int, str, intptr, intptr, var, int ; res = SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags) ; pszTargetName : LPCSTR -> "str" ; pUiInfo : void* optional -> "intptr" ; dwAuthError : DWORD -> "int" ; pszPackage : LPCSTR -> "str" ; pInputAuthIdentity : void* optional -> "intptr" ; ppAuthIdentity : void** out -> "intptr" ; pfSave : INT* optional, in/out -> "var" ; dwFlags : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SspiPromptForCredentialsA(LPCSTR pszTargetName, void* pUiInfo, DWORD dwAuthError, LPCSTR pszPackage, void* pInputAuthIdentity, void** ppAuthIdentity, INT* pfSave, DWORD dwFlags) #uselib "credui.dll" #cfunc global SspiPromptForCredentialsA "SspiPromptForCredentialsA" str, intptr, int, str, intptr, intptr, intptr, int ; res = SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, varptr(pfSave), dwFlags) ; pszTargetName : LPCSTR -> "str" ; pUiInfo : void* optional -> "intptr" ; dwAuthError : DWORD -> "int" ; pszPackage : LPCSTR -> "str" ; 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")
procSspiPromptForCredentialsA = credui.NewProc("SspiPromptForCredentialsA")
)
// pszTargetName (LPCSTR), pUiInfo (void* optional), dwAuthError (DWORD), pszPackage (LPCSTR), pInputAuthIdentity (void* optional), ppAuthIdentity (void** out), pfSave (INT* optional, in/out), dwFlags (DWORD)
r1, _, err := procSspiPromptForCredentialsA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszTargetName))),
uintptr(pUiInfo),
uintptr(dwAuthError),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszPackage))),
uintptr(pInputAuthIdentity),
uintptr(ppAuthIdentity),
uintptr(pfSave),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SspiPromptForCredentialsA(
pszTargetName: PAnsiChar; // LPCSTR
pUiInfo: Pointer; // void* optional
dwAuthError: DWORD; // DWORD
pszPackage: PAnsiChar; // LPCSTR
pInputAuthIdentity: Pointer; // void* optional
ppAuthIdentity: Pointer; // void** out
pfSave: Pointer; // INT* optional, in/out
dwFlags: DWORD // DWORD
): DWORD; stdcall;
external 'credui.dll' name 'SspiPromptForCredentialsA';result := DllCall("credui\SspiPromptForCredentialsA"
, "AStr", pszTargetName ; LPCSTR
, "Ptr", pUiInfo ; void* optional
, "UInt", dwAuthError ; DWORD
, "AStr", pszPackage ; LPCSTR
, "Ptr", pInputAuthIdentity ; void* optional
, "Ptr", ppAuthIdentity ; void** out
, "Ptr", pfSave ; INT* optional, in/out
, "UInt", dwFlags ; DWORD
, "UInt") ; return: DWORD●SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags) = DLL("credui.dll", "dword SspiPromptForCredentialsA(char*, void*, dword, char*, void*, void*, void*, dword)")
# 呼び出し: SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
# pszTargetName : LPCSTR -> "char*"
# pUiInfo : void* optional -> "void*"
# dwAuthError : DWORD -> "dword"
# pszPackage : LPCSTR -> "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)。const std = @import("std");
extern "credui" fn SspiPromptForCredentialsA(
pszTargetName: [*c]const u8, // LPCSTR
pUiInfo: ?*anyopaque, // void* optional
dwAuthError: u32, // DWORD
pszPackage: [*c]const u8, // LPCSTR
pInputAuthIdentity: ?*anyopaque, // void* optional
ppAuthIdentity: ?*anyopaque, // void** out
pfSave: [*c]i32, // INT* optional, in/out
dwFlags: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc SspiPromptForCredentialsA(
pszTargetName: cstring, # LPCSTR
pUiInfo: pointer, # void* optional
dwAuthError: uint32, # DWORD
pszPackage: cstring, # LPCSTR
pInputAuthIdentity: pointer, # void* optional
ppAuthIdentity: pointer, # void** out
pfSave: ptr int32, # INT* optional, in/out
dwFlags: uint32 # DWORD
): uint32 {.importc: "SspiPromptForCredentialsA", stdcall, dynlib: "credui.dll".}pragma(lib, "credui");
extern(Windows)
uint SspiPromptForCredentialsA(
const(char)* pszTargetName, // LPCSTR
void* pUiInfo, // void* optional
uint dwAuthError, // DWORD
const(char)* pszPackage, // LPCSTR
void* pInputAuthIdentity, // void* optional
void** ppAuthIdentity, // void** out
int* pfSave, // INT* optional, in/out
uint dwFlags // DWORD
);ccall((:SspiPromptForCredentialsA, "credui.dll"), stdcall, UInt32,
(Cstring, Ptr{Cvoid}, UInt32, Cstring, Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Int32}, UInt32),
pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
# pszTargetName : LPCSTR -> Cstring
# pUiInfo : void* optional -> Ptr{Cvoid}
# dwAuthError : DWORD -> UInt32
# pszPackage : LPCSTR -> Cstring
# pInputAuthIdentity : void* optional -> Ptr{Cvoid}
# ppAuthIdentity : void** out -> Ptr{Cvoid}
# pfSave : INT* optional, in/out -> Ptr{Int32}
# dwFlags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SspiPromptForCredentialsA(
const char* pszTargetName,
void* pUiInfo,
uint32_t dwAuthError,
const char* pszPackage,
void* pInputAuthIdentity,
void** ppAuthIdentity,
int32_t* pfSave,
uint32_t dwFlags);
]]
local credui = ffi.load("credui")
-- credui.SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
-- pszTargetName : LPCSTR
-- pUiInfo : void* optional
-- dwAuthError : DWORD
-- pszPackage : LPCSTR
-- pInputAuthIdentity : void* optional
-- ppAuthIdentity : void** out
-- pfSave : INT* optional, in/out
-- dwFlags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('credui.dll');
const SspiPromptForCredentialsA = lib.func('__stdcall', 'SspiPromptForCredentialsA', 'uint32_t', ['str', 'void *', 'uint32_t', 'str', 'void *', 'void *', 'int32_t *', 'uint32_t']);
// SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
// pszTargetName : LPCSTR -> 'str'
// pUiInfo : void* optional -> 'void *'
// dwAuthError : DWORD -> 'uint32_t'
// pszPackage : LPCSTR -> 'str'
// 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", {
SspiPromptForCredentialsA: { parameters: ["buffer", "pointer", "u32", "buffer", "pointer", "pointer", "pointer", "u32"], result: "u32" },
});
// lib.symbols.SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags)
// pszTargetName : LPCSTR -> "buffer"
// pUiInfo : void* optional -> "pointer"
// dwAuthError : DWORD -> "u32"
// pszPackage : LPCSTR -> "buffer"
// pInputAuthIdentity : void* optional -> "pointer"
// ppAuthIdentity : void** out -> "pointer"
// pfSave : INT* optional, in/out -> "pointer"
// dwFlags : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SspiPromptForCredentialsA(
const char* pszTargetName,
void* pUiInfo,
uint32_t dwAuthError,
const char* pszPackage,
void* pInputAuthIdentity,
void** ppAuthIdentity,
int32_t* pfSave,
uint32_t dwFlags);
C, "credui.dll");
// $ffi->SspiPromptForCredentialsA(pszTargetName, pUiInfo, dwAuthError, pszPackage, pInputAuthIdentity, ppAuthIdentity, pfSave, dwFlags);
// pszTargetName : LPCSTR
// pUiInfo : void* optional
// dwAuthError : DWORD
// pszPackage : LPCSTR
// 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.ASCII_OPTIONS);
int SspiPromptForCredentialsA(
String pszTargetName, // LPCSTR
Pointer pUiInfo, // void* optional
int dwAuthError, // DWORD
String pszPackage, // LPCSTR
Pointer pInputAuthIdentity, // void* optional
Pointer ppAuthIdentity, // void** out
IntByReference pfSave, // INT* optional, in/out
int dwFlags // DWORD
);
}@[Link("credui")]
lib Libcredui
fun SspiPromptForCredentialsA = SspiPromptForCredentialsA(
pszTargetName : UInt8*, # LPCSTR
pUiInfo : Void*, # void* optional
dwAuthError : UInt32, # DWORD
pszPackage : UInt8*, # LPCSTR
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 SspiPromptForCredentialsANative = Uint32 Function(Pointer<Utf8>, Pointer<Void>, Uint32, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, Pointer<Int32>, Uint32);
typedef SspiPromptForCredentialsADart = int Function(Pointer<Utf8>, Pointer<Void>, int, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, Pointer<Int32>, int);
final SspiPromptForCredentialsA = DynamicLibrary.open('credui.dll')
.lookupFunction<SspiPromptForCredentialsANative, SspiPromptForCredentialsADart>('SspiPromptForCredentialsA');
// pszTargetName : LPCSTR -> Pointer<Utf8>
// pUiInfo : void* optional -> Pointer<Void>
// dwAuthError : DWORD -> Uint32
// pszPackage : LPCSTR -> Pointer<Utf8>
// 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 SspiPromptForCredentialsA(
pszTargetName: PAnsiChar; // LPCSTR
pUiInfo: Pointer; // void* optional
dwAuthError: DWORD; // DWORD
pszPackage: PAnsiChar; // LPCSTR
pInputAuthIdentity: Pointer; // void* optional
ppAuthIdentity: Pointer; // void** out
pfSave: Pointer; // INT* optional, in/out
dwFlags: DWORD // DWORD
): DWORD; stdcall;
external 'credui.dll' name 'SspiPromptForCredentialsA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SspiPromptForCredentialsA"
c_SspiPromptForCredentialsA :: CString -> Ptr () -> Word32 -> CString -> Ptr () -> Ptr () -> Ptr Int32 -> Word32 -> IO Word32
-- pszTargetName : LPCSTR -> CString
-- pUiInfo : void* optional -> Ptr ()
-- dwAuthError : DWORD -> Word32
-- pszPackage : LPCSTR -> CString
-- 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 sspipromptforcredentialsa =
foreign "SspiPromptForCredentialsA"
(string @-> (ptr void) @-> uint32_t @-> string @-> (ptr void) @-> (ptr void) @-> (ptr int32_t) @-> uint32_t @-> returning uint32_t)
(* pszTargetName : LPCSTR -> string *)
(* pUiInfo : void* optional -> (ptr void) *)
(* dwAuthError : DWORD -> uint32_t *)
(* pszPackage : LPCSTR -> string *)
(* 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 ("SspiPromptForCredentialsA" sspi-prompt-for-credentials-a :convention :stdcall) :uint32
(psz-target-name :string) ; LPCSTR
(p-ui-info :pointer) ; void* optional
(dw-auth-error :uint32) ; DWORD
(psz-package :string) ; LPCSTR
(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 $SspiPromptForCredentialsA = Win32::API::More->new('credui',
'DWORD SspiPromptForCredentialsA(LPCSTR pszTargetName, LPVOID pUiInfo, DWORD dwAuthError, LPCSTR pszPackage, LPVOID pInputAuthIdentity, LPVOID ppAuthIdentity, LPVOID pfSave, DWORD dwFlags)');
# my $ret = $SspiPromptForCredentialsA->Call($pszTargetName, $pUiInfo, $dwAuthError, $pszPackage, $pInputAuthIdentity, $ppAuthIdentity, $pfSave, $dwFlags);
# pszTargetName : LPCSTR -> LPCSTR
# pUiInfo : void* optional -> LPVOID
# dwAuthError : DWORD -> DWORD
# pszPackage : LPCSTR -> LPCSTR
# pInputAuthIdentity : void* optional -> LPVOID
# ppAuthIdentity : void** out -> LPVOID
# pfSave : INT* optional, in/out -> LPVOID
# dwFlags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SspiPromptForCredentialsW (Unicode版) — 資格情報入力用のダイアログを表示してユーザーから認証情報を取得する(Unicode版)。