幾乎每個應用系統都有相應的權限管理功能
設計流程為
在Delphi開發環境中
增加函數Wsz_IfFirst
//判斷是否是第一次使用
function Wsz_IfFirst:Boolean;
var
sUser:string;
sPass:string;
begin
result := false;
RegF:=TRegistry
RegF
RegF
sUser := RegF
sPass := RegF
if ((length(sUser)=
result := true ;
RegF
end;
file://判斷用戶名和口令是否正確
function Wsz_CheckUser(MyUser:string;MyPass :string):Boolean;
var
sUser:string;
sPass:string;
begin
result:= false;
RegF:=TRegistry
RegF
RegF
sUser := RegF
sPass := RegF
if (sUser=MyUser) and (sPass=MyPass) then
result := true;
RegF
end;
file://保存用戶名和口令
procedure Wsz_SaveUser(MyUser:string;MyPass :string);
begin
RegF:=TRegistry
RegF
RegF
RegF
RegF
RegF
end;
file://取消按紐事件
procedure TWszLoginForm
begin
Close;
end;
file://確定按紐事件
procedure TWszLoginForm
var
suser:string;
spass:string;
begin
suser := trim(edituser
spass := trim(editpass
if (length(suser)=
begin
Application
MB_OK + MB_ICONINFORMATION);
edituser
exit;
end;
if Wsz_IfFirst then
begin
file://處理第一次登錄的用戶名和口令
if Application
以便下次登錄
MB_OKCANCEL + MB_ICONQUESTION) = IDOK then
begin
file://保存
Wsz_SaveUser(suser
end
else
begin
edituser
exit;
end;
end else
begin
if not Wsz_CheckUser(suser
begin
Application
(
MB_OK + MB_ICONINFORMATION);
edituser
exit;
end;
end;
file://全局變量
GB_Wsz_User := suser;
GB_Wsz_PASS := spass;
Close;
end;
file://窗體的Show事件
procedure TWszLoginForm
begin
if Wsz_IfFirst then
begin
Application
MB_OK + MB_ICONINFORMATION);
end;
end;
From:http://tw.wingwit.com/Article/os/xtgl/201405/30895.html