不会啊,楼主,我这里都是可以的
static function TINIT.InternalLogon: Boolean;
const
MaxLogonFailCount = 3;
LogonErrorMsg01 = '登录失败';
LogonErrorMsg02 = '用户不存在或者密码错误,请注意大小写,密码是区分大小写的。';
LogonErrorMsg03 = '对不起,您已经 %d 次登录失败,将退出系统。';
var
I: Integer;
lAccept: Boolean;
sUser, sPass, lAccountID, lUserID: String;
lIniFile: TIniFile;
lIniFileName: String;
begin
if not FInternalDisableAutoLogon then
begin
if UseAD and LoginUseAD then
begin
Dialogs.ShowMessage('通过AD登陆');
Result := True;
Exit;
end;
end;
lIniFileName := jsCommon.ModulePath + 'Business.ini';
lIniFile := TIniFile.Create(lIniFileName);
try
sUser := lIniFile.ReadString('System', 'LastLogonUserID', '');
sPass := '';
I := MaxLogonFailCount;
repeat
if I <> MaxLogonFailCount then
Dialogs.MessageDlg(LogonErrorMsg02, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK] , 0);
lAccept := TSystemCore.SystemInterface.ShowLogonForm(sUser, sPass);
if not lAccept then Break;
// IE嵌入登陆 sUser的返回可以为空(这个方案不好,为了做嵌入IE登陆)
if sUser <> '' then
begin
lAccountID := sUser;
lUserID := JSCommon.SplitStr('@', lAccountID);
BizSys.BizSystem.ClientAccount := lAccountID;
Result := (not Opr.IsSystemManager(lUserID) or ExtUtils.ClientAccountExist(BizSys.BizSystem.ClientAccount)) and
TSystemCore.Logon(lUserID, sPass);
end
else
Result := True;
if Result then Break;
Dec(I);
until I = 0;
if Result then
try
lIniFile.WriteString('System', 'LastLogonUserID', sUser);
Dialogs.Showmessage('用户名登陆成功!');
except
end
else
if lAccept then
Dialogs.MessageDlg(SysUtils.Format(LogonErrorMsg03, [MaxLogonFailCount]),
TMsgDlgType.mtError, [TMsgDlgBtn.mbOK] , 0);
finally
lIniFile.Free;
end;
end; |