⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit2.~pas

📁 一个RFID上位机软件
💻 ~PAS
字号:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Bevel1: TBevel;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    ComboBox1: TComboBox;
    ComboBox5: TComboBox;
    ComboBox4: TComboBox;
    ComboBox3: TComboBox;
    ComboBox2: TComboBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Edit1: TEdit;
    Label6: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;
{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
  ComboBox1.Text:=Form1.Comm1.CommName;
  ComboBox2.Text:=Inttostr(Form1.Comm1.BaudRate);
end;

procedure TForm2.BitBtn1Click(Sender: TObject);
var
  MyReg:TRegistry;
begin
  Form1.Comm1.StopComm;
  Form1.UDPClient1.Active:=False;
  Form1.Comm1.CommName:=ComboBox1.Text;
  Form1.Comm1.BaudRate:=StrToInt(ComboBox2.Text);
  Form1.UDPClient1.Host:=Trim(Edit1.Text);

  Form1.Comm1.StartComm;
  Form1.UDPClient1.Active:=True;
  MyReg:=TRegistry.Create;
  MyReg.RootKey:=HKEY_LOCAL_MACHINE;
  try
    if not MyReg.OpenKey('\SOFTWARE\WDCJ',FALSE)then
      begin
        Form1.StatusBar1.Panels[0].Text:='打开注册表失败!';
        MyReg.CloseKey;
      end
    else
      begin
        MyReg.WriteString('COM',ComboBox1.Text);
        MyReg.WriteInteger('BaudRate',StrToInt(ComboBox2.Text));
        MyReg.CloseKey;
        Form1.StatusBar1.Panels[0].Text:='通信设置成功!';
      end;
  finally
    MyReg.Free;
  end;
  Close;
end;

procedure TForm2.BitBtn2Click(Sender: TObject);
begin
  Close;
end;

end.

⌨️ 快捷键说明

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