请大家帮我看看,这程序哪些地方有问题,万分感激,小弟刚接触些语言,好多东东还不太明白,还望指教
unit FrmLogin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TFrm_Login = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
pwd: TEdit;
name: TComboBox;
BtOK: TButton;
BtCancel: TButton;
procedure FormCreate(Sender: TObject);
procedure BtCancelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function canPass : Boolean; //判断是否能够成功登陆
end;
var
Frm_Login: TFrm_Login;
power : string; //根据配置文件获得用户权限
result : Boolean;
function TFrmLogin.canpass : boolean;
var
f: file; //文件类型变量
s1,s2,s3 : string[30];
nr : string; //读出的字节数
begin
repeat
blockread(f,s1,12,nr);
blockread(f,s2,12,nr);
blockread(f,s3,24,nr);
//用户名和密码正确
if (s1=name.text) and (s2=pwd.text) then
begin
power :=s3;
closefile(f);
result :=true;
exit;
end;
until(nr=0);
closefile(f);
result :=false;
end;
end;
implementation
{$R *.dfm}
procedure TFrm_Login.FormCreate(Sender: TObject);
var
f: file;
nr,nw: integer;
buf: string[60];
bn : boolean;
size :longint;
begin
assignFile('sys.ini');
bn:=true;
if fileExists('sys.ini')=false then //配置文件不存在
bn:=false;
else
begin
reSet(f,1);
size:=fileSize(f);
if size <48 then //配置文件不合法
bn:=false;
end;
if bn=false then //新建一个系统配置文件
begin
reWrite(f,1);
buf :='admin';
blockWrite(f,buf,12,nw);
buf :='admin';
blockWrite(f,buf,12,nw);
buf :='1';
blockWrite(f,buf,24,nw);
closeFile(f);
end;
reSet(f,1);
repeat
bloceRead(f,buf,12,nr);
if nr>0 then
name.items.add(buf);
blockRead(f.buf,12,nr);
blockRead(f,buf,24,nr);
until(nr=0);
closeFile(f);
end;
procedure TFrm_Login.BtCancelClick(Sender: TObject);
begin
close;
end;
end.