函数参考


_WinAPI_ConfirmCredentials

Confirms the validity of the credential harvested.

#Include <WinAPIEx.au3>
_WinAPI_ConfirmCredentials ( $sTarget, $fConfirm )

参数

$sTarget The string that contains the name of the target for the credentials, typically a domain or server name.
This must be the same value passed to _WinAPI_ShellUserAuthenticationDlg() function.
$fConfirm Specifies whether the credentials returned from the prompt function are valid, valid values:
TRUE - The credentials are stored in the credential manager.
FALSE - The credentials are not stored and various pieces of memory are cleaned up.

返回值

成功: 返回 1.
失败: 返回 0 并设置 @error 标志为非 0 值, @extended 标志可能包含一个系统错误代码.

注意/说明

This function function must be called after each successful call to _WinAPI_ShellUserAuthenticationDlg()
with the $CREDUI_FLAGS_EXPECT_CONFIRMATION flag set.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#Include <String.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Authentication.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Global $Data[3] = ['', '', 0]

While 1
    $Data = _WinAPI_ShellUserAuthenticationDlg('Authentication', 'To continue, type a login and password, and then click OK.', $Data[0], $Data[1], 'MyScript', BitOR($CREDUI_FLAGS_ALWAYS_SHOW_UI, $CREDUI_FLAGS_EXPECT_CONFIRMATION, $CREDUI_FLAGS_GENERIC_CREDENTIALS, $CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX), 0, $Data[2], $hBitmap)
    If @error Then
        Exit
    EndIf
    If (StringCompare($Data[0], 'AutoIt')) Or (StringCompare($Data[1], _StringEncrypt(0, 'DC7E430A1C88', '123'))) Then
        If $Data[2] Then
            _WinAPI_ConfirmCredentials('MyScript', 0)
        EndIf
        MsgBox(16, 'Error', 'You have typed an incorrect login or password, it should be "AutoIt" and "123".')
    Else
        If $Data[2] Then
            _WinAPI_ConfirmCredentials('MyScript', 1)
        EndIf
        ExitLoop
    EndIf
WEnd