mainu.pas

来自「Delphi basic program. Basic programing」· PAS 代码 · 共 57 行

PAS
57
字号
unit MainU;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    SetButton: TButton;
    TestButton: TButton;
    Label1: TLabel;
    procedure SetButtonClick(Sender: TObject);
    procedure TestButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    Password:PChar;
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
function GetPassWord(word:PChar):Boolean;
far; external 'PassForm.dll';
function SetPassWord(word:PChar):Boolean;
far; external 'PassForm.dll';


procedure TForm1.SetButtonClick(Sender: TObject);
begin
  PassWord := StrAlloc(40);
  if SetPassWord(PassWord) = False then
    MessageDlg('PassWord is not set',mtInformation,[mbOK],0);
end;

procedure TForm1.TestButtonClick(Sender: TObject);
begin
  if PassWord = nil then
  begin
    MessageDlg('Set password first',mtInformation,[mbOK],0);
    SetButton.SetFocus;
    Exit;
  end;
  if GetPassword(PassWord) then
    Label1.Caption := 'You are Wellcome!'
  else
    Label1.Caption := 'Sorry,You are Invalid User.';  
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?