//判断是否是第一次使用
function Wsz_IfFirst:Boolean;
var
sUser:string;
sPass:string;
begin
result := false;
RegF:=TRegistryCreate;
RegFRootKey :=HKEY_LOCAL_MACHINE;
RegFOpenKey(SOFTWARE\MicroSoft\whhTRUE);
sUser := RegFReadString(user);
sPass := RegFReadString(pass);
if ((length(sUser)<=) and (length(sPass)<=)) then
result := true ;
RegFFree;
end;
file://判断用户名和口令是否正确
function Wsz_CheckUser(MyUser:string;MyPass :string):Boolean;
var
sUser:string;
sPass:string;
begin
result:= false;
RegF:=TRegistryCreate;
RegFRootKey :=HKEY_LOCAL_MACHINE;
RegFOpenKey(SOFTWARE\MicroSoft\whhTRUE);
sUser := RegFReadString(user);
sPass := RegFReadString(pass);
if (sUser=MyUser) and (sPass=MyPass) then
result := true;
RegFFree;
end;
file://保存用户名和口令
procedure Wsz_SaveUser(MyUser:string;MyPass :string);
begin
RegF:=TRegistryCreate;
RegFRootKey :=HKEY_LOCAL_MACHINE;
RegFOpenKey(SOFTWARE\MicroSoft\whhTRUE);
RegFWriteString(userMyUser);
RegFWriteString(passMyPass);
RegFFree;
end;
file://取消按纽事件
procedure TWszLoginFormBitBtnCloseClick(Sender: TObject);
begin
Close;
end;
file://确定按纽事件
procedure TWszLoginFormBitBtnYesClick(Sender: TObject);
var
suser:string;
spass:string;
begin
suser := trim(editusertext);
spass := trim(editpasstext);
if (length(suser)<=) or (length(spass)<=) then
begin
ApplicationMessageBox(用户名和口令都必须输入!
系统提示
MB_OK + MB_ICONINFORMATION);
edituserSetFocus ;
exit;
end;
if Wsz_IfFirst then
begin
file://处理第一次登录的用户名和口令
if ApplicationMessageBox(
您是第一次使用本软件请记住您的用户名和口令
以便下次登录现在进入系统吗?
系统提示
MB_OKCANCEL + MB_ICONQUESTION) = IDOK then
begin
file://保存
Wsz_SaveUser(suserspass);
end
else
begin
edituserSetFocus ;
exit;
end;
end else
begin
if not Wsz_CheckUser(suserspass) then
begin
ApplicationMessageBox
(对不起用户名和口令输入不正确! 系统提示
MB_OK + MB_ICONINFORMATION);
editusersetfocus ;
exit;
end;
end;
file://全局变量
GB_Wsz_User := suser;
GB_Wsz_PASS := spass;
Close;
end;
file://窗体的Show事件
procedure TWszLoginFormFormShow(Sender: TObject);
begin
if Wsz_IfFirst then
begin
ApplicationMessageBox(
您是第一次使用本软件您可以随便输入用户名和口令
系统提示
MB_OK + MB_ICONINFORMATION);
end;
end;