procedure TForm1.BitBtn1Click(Sender: TObject); //确认 begin try With Table1 do begin Active:=False; TableName:=ExtractFilePath(Application.ExeName)+'log.dbf'; Active:=True; //打开数据库(此处用的是DBase数据库) First; While not Eof do begin if ComboBox1.Text=Fields.Fields[0].AsString then //查找用户名 begin if Edit1.Text=Fields.Fields[1].AsString then //密码正确 begin MessageDlg('登录成功!',mtConfirmation,[mbOK],0); Form2.Show; //注:若要用到两个窗体,在Form1的Unit1文件中必须引用Unit2.pas //Form1.Hide; end else begin //密码错误 MessageDlg('密码错误!',mtConfirmation,[mbOK],0); end; break; end; Next; end; if Eof then //未找到用户名 begin MessageDlg('该用户名不存在!',mtConfirmation,[mbOK],0); end; end; except end; end;
begin
try
With Table1 do
begin
Active:=False;
TableName:=ExtractFilePath(Application.ExeName)+'log.dbf';
Active:=True; //打开数据库(此处用的是DBase数据库) First;
While not Eof do
begin
if ComboBox1.Text=Fields.Fields[0].AsString then //查找用户名
begin
if Edit1.Text=Fields.Fields[1].AsString then //密码正确
begin
MessageDlg('登录成功!',mtConfirmation,[mbOK],0);
Form2.Show; //注:若要用到两个窗体,在Form1的Unit1文件中必须引用Unit2.pas
//Form1.Hide;
end
else begin //密码错误
MessageDlg('密码错误!',mtConfirmation,[mbOK],0);
end;
break;
end;
Next;
end;
if Eof then //未找到用户名
begin
MessageDlg('该用户名不存在!',mtConfirmation,[mbOK],0);
end;
end;
except
end;
end;
我不会.UP一下
var
buf: array[0..255] of char;
i: DWORD;
begin
i:= 256;
GetUserName(buf,i);
showmessage(buf);
end;