ホーム › Security.Credentials › CredUIPromptForCredentialsA
CredUIPromptForCredentialsA
関数ユーザー名とパスワードの入力ダイアログを表示する。
シグネチャ
// credui.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR CredUIPromptForCredentialsA(
CREDUI_INFOA* pUiInfo, // optional
LPCSTR pszTargetName, // optional
SecHandle* pContext, // optional
DWORD dwAuthError,
LPSTR pszUserName,
DWORD ulUserNameBufferSize,
LPSTR pszPassword,
DWORD ulPasswordBufferSize,
BOOL* save, // optional
CREDUI_FLAGS dwFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pUiInfo | CREDUI_INFOA* | inoptional |
| pszTargetName | LPCSTR | inoptional |
| pContext | SecHandle* | optional |
| dwAuthError | DWORD | in |
| pszUserName | LPSTR | inout |
| ulUserNameBufferSize | DWORD | in |
| pszPassword | LPSTR | inout |
| ulPasswordBufferSize | DWORD | in |
| save | BOOL* | inoutoptional |
| dwFlags | CREDUI_FLAGS | in |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// credui.dll (ANSI / -A)
#include <windows.h>
WIN32_ERROR CredUIPromptForCredentialsA(
CREDUI_INFOA* pUiInfo, // optional
LPCSTR pszTargetName, // optional
SecHandle* pContext, // optional
DWORD dwAuthError,
LPSTR pszUserName,
DWORD ulUserNameBufferSize,
LPSTR pszPassword,
DWORD ulPasswordBufferSize,
BOOL* save, // optional
CREDUI_FLAGS dwFlags
);[DllImport("credui.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint CredUIPromptForCredentialsA(
IntPtr pUiInfo, // CREDUI_INFOA* optional
[MarshalAs(UnmanagedType.LPStr)] string pszTargetName, // LPCSTR optional
IntPtr pContext, // SecHandle* optional
uint dwAuthError, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszUserName, // LPSTR in/out
uint ulUserNameBufferSize, // DWORD
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszPassword, // LPSTR in/out
uint ulPasswordBufferSize, // DWORD
IntPtr save, // BOOL* optional, in/out
uint dwFlags // CREDUI_FLAGS
);<DllImport("credui.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function CredUIPromptForCredentialsA(
pUiInfo As IntPtr, ' CREDUI_INFOA* optional
<MarshalAs(UnmanagedType.LPStr)> pszTargetName As String, ' LPCSTR optional
pContext As IntPtr, ' SecHandle* optional
dwAuthError As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszUserName As System.Text.StringBuilder, ' LPSTR in/out
ulUserNameBufferSize As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> pszPassword As System.Text.StringBuilder, ' LPSTR in/out
ulPasswordBufferSize As UInteger, ' DWORD
save As IntPtr, ' BOOL* optional, in/out
dwFlags As UInteger ' CREDUI_FLAGS
) As UInteger
End Function' pUiInfo : CREDUI_INFOA* optional
' pszTargetName : LPCSTR optional
' pContext : SecHandle* optional
' dwAuthError : DWORD
' pszUserName : LPSTR in/out
' ulUserNameBufferSize : DWORD
' pszPassword : LPSTR in/out
' ulPasswordBufferSize : DWORD
' save : BOOL* optional, in/out
' dwFlags : CREDUI_FLAGS
Declare PtrSafe Function CredUIPromptForCredentialsA Lib "credui" ( _
ByVal pUiInfo As LongPtr, _
ByVal pszTargetName As String, _
ByVal pContext As LongPtr, _
ByVal dwAuthError As Long, _
ByVal pszUserName As String, _
ByVal ulUserNameBufferSize As Long, _
ByVal pszPassword As String, _
ByVal ulPasswordBufferSize As Long, _
ByVal save 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
CredUIPromptForCredentialsA = ctypes.windll.credui.CredUIPromptForCredentialsA
CredUIPromptForCredentialsA.restype = wintypes.DWORD
CredUIPromptForCredentialsA.argtypes = [
ctypes.c_void_p, # pUiInfo : CREDUI_INFOA* optional
wintypes.LPCSTR, # pszTargetName : LPCSTR optional
ctypes.c_void_p, # pContext : SecHandle* optional
wintypes.DWORD, # dwAuthError : DWORD
wintypes.LPSTR, # pszUserName : LPSTR in/out
wintypes.DWORD, # ulUserNameBufferSize : DWORD
wintypes.LPSTR, # pszPassword : LPSTR in/out
wintypes.DWORD, # ulPasswordBufferSize : DWORD
ctypes.c_void_p, # save : BOOL* optional, in/out
wintypes.DWORD, # dwFlags : CREDUI_FLAGS
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('credui.dll')
CredUIPromptForCredentialsA = Fiddle::Function.new(
lib['CredUIPromptForCredentialsA'],
[
Fiddle::TYPE_VOIDP, # pUiInfo : CREDUI_INFOA* optional
Fiddle::TYPE_VOIDP, # pszTargetName : LPCSTR optional
Fiddle::TYPE_VOIDP, # pContext : SecHandle* optional
-Fiddle::TYPE_INT, # dwAuthError : DWORD
Fiddle::TYPE_VOIDP, # pszUserName : LPSTR in/out
-Fiddle::TYPE_INT, # ulUserNameBufferSize : DWORD
Fiddle::TYPE_VOIDP, # pszPassword : LPSTR in/out
-Fiddle::TYPE_INT, # ulPasswordBufferSize : DWORD
Fiddle::TYPE_VOIDP, # save : BOOL* optional, in/out
-Fiddle::TYPE_INT, # dwFlags : CREDUI_FLAGS
],
-Fiddle::TYPE_INT)#[link(name = "credui")]
extern "system" {
fn CredUIPromptForCredentialsA(
pUiInfo: *mut CREDUI_INFOA, // CREDUI_INFOA* optional
pszTargetName: *const u8, // LPCSTR optional
pContext: *mut SecHandle, // SecHandle* optional
dwAuthError: u32, // DWORD
pszUserName: *mut u8, // LPSTR in/out
ulUserNameBufferSize: u32, // DWORD
pszPassword: *mut u8, // LPSTR in/out
ulPasswordBufferSize: u32, // DWORD
save: *mut i32, // BOOL* optional, in/out
dwFlags: u32 // CREDUI_FLAGS
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("credui.dll", CharSet = CharSet.Ansi)]
public static extern uint CredUIPromptForCredentialsA(IntPtr pUiInfo, [MarshalAs(UnmanagedType.LPStr)] string pszTargetName, IntPtr pContext, uint dwAuthError, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszUserName, uint ulUserNameBufferSize, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszPassword, uint ulPasswordBufferSize, IntPtr save, uint dwFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'credui_CredUIPromptForCredentialsA' -Namespace Win32 -PassThru
# $api::CredUIPromptForCredentialsA(pUiInfo, pszTargetName, pContext, dwAuthError, pszUserName, ulUserNameBufferSize, pszPassword, ulPasswordBufferSize, save, dwFlags)#uselib "credui.dll"
#func global CredUIPromptForCredentialsA "CredUIPromptForCredentialsA" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; CredUIPromptForCredentialsA varptr(pUiInfo), pszTargetName, varptr(pContext), dwAuthError, varptr(pszUserName), ulUserNameBufferSize, varptr(pszPassword), ulPasswordBufferSize, save, dwFlags ; 戻り値は stat
; pUiInfo : CREDUI_INFOA* optional -> "sptr"
; pszTargetName : LPCSTR optional -> "sptr"
; pContext : SecHandle* optional -> "sptr"
; dwAuthError : DWORD -> "sptr"
; pszUserName : LPSTR in/out -> "sptr"
; ulUserNameBufferSize : DWORD -> "sptr"
; pszPassword : LPSTR in/out -> "sptr"
; ulPasswordBufferSize : DWORD -> "sptr"
; save : BOOL* optional, in/out -> "sptr"
; dwFlags : CREDUI_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "credui.dll" #cfunc global CredUIPromptForCredentialsA "CredUIPromptForCredentialsA" var, str, var, int, var, int, var, int, int, int ; res = CredUIPromptForCredentialsA(pUiInfo, pszTargetName, pContext, dwAuthError, pszUserName, ulUserNameBufferSize, pszPassword, ulPasswordBufferSize, save, dwFlags) ; pUiInfo : CREDUI_INFOA* optional -> "var" ; pszTargetName : LPCSTR optional -> "str" ; pContext : SecHandle* optional -> "var" ; dwAuthError : DWORD -> "int" ; pszUserName : LPSTR in/out -> "var" ; ulUserNameBufferSize : DWORD -> "int" ; pszPassword : LPSTR in/out -> "var" ; ulPasswordBufferSize : DWORD -> "int" ; save : BOOL* optional, in/out -> "int" ; dwFlags : CREDUI_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "credui.dll" #cfunc global CredUIPromptForCredentialsA "CredUIPromptForCredentialsA" sptr, str, sptr, int, sptr, int, sptr, int, int, int ; res = CredUIPromptForCredentialsA(varptr(pUiInfo), pszTargetName, varptr(pContext), dwAuthError, varptr(pszUserName), ulUserNameBufferSize, varptr(pszPassword), ulPasswordBufferSize, save, dwFlags) ; pUiInfo : CREDUI_INFOA* optional -> "sptr" ; pszTargetName : LPCSTR optional -> "str" ; pContext : SecHandle* optional -> "sptr" ; dwAuthError : DWORD -> "int" ; pszUserName : LPSTR in/out -> "sptr" ; ulUserNameBufferSize : DWORD -> "int" ; pszPassword : LPSTR in/out -> "sptr" ; ulPasswordBufferSize : DWORD -> "int" ; save : BOOL* optional, in/out -> "int" ; dwFlags : CREDUI_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR CredUIPromptForCredentialsA(CREDUI_INFOA* pUiInfo, LPCSTR pszTargetName, SecHandle* pContext, DWORD dwAuthError, LPSTR pszUserName, DWORD ulUserNameBufferSize, LPSTR pszPassword, DWORD ulPasswordBufferSize, BOOL* save, CREDUI_FLAGS dwFlags) #uselib "credui.dll" #cfunc global CredUIPromptForCredentialsA "CredUIPromptForCredentialsA" var, str, var, int, var, int, var, int, int, int ; res = CredUIPromptForCredentialsA(pUiInfo, pszTargetName, pContext, dwAuthError, pszUserName, ulUserNameBufferSize, pszPassword, ulPasswordBufferSize, save, dwFlags) ; pUiInfo : CREDUI_INFOA* optional -> "var" ; pszTargetName : LPCSTR optional -> "str" ; pContext : SecHandle* optional -> "var" ; dwAuthError : DWORD -> "int" ; pszUserName : LPSTR in/out -> "var" ; ulUserNameBufferSize : DWORD -> "int" ; pszPassword : LPSTR in/out -> "var" ; ulPasswordBufferSize : DWORD -> "int" ; save : BOOL* optional, in/out -> "int" ; dwFlags : CREDUI_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR CredUIPromptForCredentialsA(CREDUI_INFOA* pUiInfo, LPCSTR pszTargetName, SecHandle* pContext, DWORD dwAuthError, LPSTR pszUserName, DWORD ulUserNameBufferSize, LPSTR pszPassword, DWORD ulPasswordBufferSize, BOOL* save, CREDUI_FLAGS dwFlags) #uselib "credui.dll" #cfunc global CredUIPromptForCredentialsA "CredUIPromptForCredentialsA" intptr, str, intptr, int, intptr, int, intptr, int, int, int ; res = CredUIPromptForCredentialsA(varptr(pUiInfo), pszTargetName, varptr(pContext), dwAuthError, varptr(pszUserName), ulUserNameBufferSize, varptr(pszPassword), ulPasswordBufferSize, save, dwFlags) ; pUiInfo : CREDUI_INFOA* optional -> "intptr" ; pszTargetName : LPCSTR optional -> "str" ; pContext : SecHandle* optional -> "intptr" ; dwAuthError : DWORD -> "int" ; pszUserName : LPSTR in/out -> "intptr" ; ulUserNameBufferSize : DWORD -> "int" ; pszPassword : LPSTR in/out -> "intptr" ; ulPasswordBufferSize : DWORD -> "int" ; save : BOOL* optional, in/out -> "int" ; dwFlags : CREDUI_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
credui = windows.NewLazySystemDLL("credui.dll")
procCredUIPromptForCredentialsA = credui.NewProc("CredUIPromptForCredentialsA")
)
// pUiInfo (CREDUI_INFOA* optional), pszTargetName (LPCSTR optional), pContext (SecHandle* optional), dwAuthError (DWORD), pszUserName (LPSTR in/out), ulUserNameBufferSize (DWORD), pszPassword (LPSTR in/out), ulPasswordBufferSize (DWORD), save (BOOL* optional, in/out), dwFlags (CREDUI_FLAGS)
r1, _, err := procCredUIPromptForCredentialsA.Call(
uintptr(pUiInfo),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszTargetName))),
uintptr(pContext),
uintptr(dwAuthError),
uintptr(pszUserName),
uintptr(ulUserNameBufferSize),
uintptr(pszPassword),
uintptr(ulPasswordBufferSize),
uintptr(save),
uintptr(dwFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction CredUIPromptForCredentialsA(
pUiInfo: Pointer; // CREDUI_INFOA* optional
pszTargetName: PAnsiChar; // LPCSTR optional
pContext: Pointer; // SecHandle* optional
dwAuthError: DWORD; // DWORD
pszUserName: PAnsiChar; // LPSTR in/out
ulUserNameBufferSize: DWORD; // DWORD
pszPassword: PAnsiChar; // LPSTR in/out
ulPasswordBufferSize: DWORD; // DWORD
save: Pointer; // BOOL* optional, in/out
dwFlags: DWORD // CREDUI_FLAGS
): DWORD; stdcall;
external 'credui.dll' name 'CredUIPromptForCredentialsA';result := DllCall("credui\CredUIPromptForCredentialsA"
, "Ptr", pUiInfo ; CREDUI_INFOA* optional
, "AStr", pszTargetName ; LPCSTR optional
, "Ptr", pContext ; SecHandle* optional
, "UInt", dwAuthError ; DWORD
, "Ptr", pszUserName ; LPSTR in/out
, "UInt", ulUserNameBufferSize ; DWORD
, "Ptr", pszPassword ; LPSTR in/out
, "UInt", ulPasswordBufferSize ; DWORD
, "Ptr", save ; BOOL* optional, in/out
, "UInt", dwFlags ; CREDUI_FLAGS
, "UInt") ; return: WIN32_ERROR●CredUIPromptForCredentialsA(pUiInfo, pszTargetName, pContext, dwAuthError, pszUserName, ulUserNameBufferSize, pszPassword, ulPasswordBufferSize, save, dwFlags) = DLL("credui.dll", "dword CredUIPromptForCredentialsA(void*, char*, void*, dword, char*, dword, char*, dword, void*, dword)")
# 呼び出し: CredUIPromptForCredentialsA(pUiInfo, pszTargetName, pContext, dwAuthError, pszUserName, ulUserNameBufferSize, pszPassword, ulPasswordBufferSize, save, dwFlags)
# pUiInfo : CREDUI_INFOA* optional -> "void*"
# pszTargetName : LPCSTR optional -> "char*"
# pContext : SecHandle* optional -> "void*"
# dwAuthError : DWORD -> "dword"
# pszUserName : LPSTR in/out -> "char*"
# ulUserNameBufferSize : DWORD -> "dword"
# pszPassword : LPSTR in/out -> "char*"
# ulPasswordBufferSize : DWORD -> "dword"
# save : BOOL* optional, in/out -> "void*"
# dwFlags : CREDUI_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。