📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Winsock,Buttons,IniFiles,DB,ShellAPI;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label7: TLabel;
UpDate: TLabel;
UpDateMe: TLabel;
UpDateMe0: TLabel;
UpDateMe1: TLabel;
UpDateMe2: TLabel;
UpDateMe3: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure UpDateMe1Click(Sender: TObject);
procedure UpDateMe0Click(Sender: TObject);
procedure UpDateMe3Click(Sender: TObject);
public
ip,http,IP1,IP2,usr,Pwd,FileName:string;UpdateBad:Boolean;
end;
var
Form1: TForm1;
implementation
uses Unit2, WLFtp, Unit4, PubFun;
{$R *.dfm}
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
halt;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if DM.NewVer>UpDate.Caption then
Begin Msg1('请先单击本窗体右下角超级链接更新版本!!!'#13#10);exit;end;
Form2.show;self.Hide;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
halt;
end;
procedure TForm1.FormShow(Sender: TObject);
var CPUname,IP,IDE,host:string;sp:Real;CPUId:Cardinal;
begin
if FileExists(ExtractFilePath(Application.ExeName)+'$$b$$.bat') then
DeleteFile(ExtractFilePath(Application.ExeName)+'$$b$$.bat');
sp:=GetCPUSpeed;IP:=GetIP(host);IDE:=GetIdeSerialNumber();
CPUId:=GetCpuID(CPUname);//i:=CPUId;
Label4.Caption:=Format('CPU为%s:%u 主频%fMHz IP=%s:%s DS=%s',[CPUname,CPUId,sp,host,IP,IDE]);
UpdateBad:=not DM.UpDateC(http,IP1,IP2,usr,Pwd,FileName);
if UpdateBad then exit;
end;
procedure TForm1.UpDateMe1Click(Sender: TObject);
var f:TWLFtp;
begin
if UpdateBad then exit;
TLabel(Sender).Visible:=false;
Application.ProcessMessages;
if pos('1',TLabel(Sender).Name)>0 then
Ip:=IP1 else Ip:=IP2;//更新IP
f:=TWLFtp.Create(Ip,usr,Pwd,21);//用户名与口令及端口
if not f.Connect then
begin Msg1(TLabel(Sender).Caption+'连接失败!请单击另一个更新地址!');exit;end;
f.DownloadFile(pchar(FileName), //下载远程的MyName='Mis.exe'并另存为'new.exe'
pchar(ExtractFilePath(application.ExeName)+'new.exe'));
f.Disconnect;
f.Free; //将'new.exe'替换成本程序
ReplaceMe1(pchar(application.exename)); Application.Terminate;
end;
procedure TForm1.UpDateMe0Click(Sender: TObject);
var s:string;
begin
if UpdateBad then exit;
TLabel(Sender).Visible:=false;DM.ADODataSet1.Close;
s:='Select 文件 From 当前 where 软件='''+Unit4.MyName+''' and 版本>'''+Update.Caption+'''';
DM.ADODataSet1.CommandText:=s;
DM.ADODataSet1.Open;
if (DM.ADODataSet1.RecordCount<1)or(DM.ADODataSet1['文件']=null) then
Begin Msg1('数据库中文件不存在或版本更低!');Exit;end;
TBlobField(DM.ADODataSet1.FieldByName('文件')).SaveToFile(ExtractFilePath(application.ExeName)+'new.exe');
DM.ADODataSet1.Close;
ReplaceMe1(pchar(application.exename)); Application.Terminate;
end;
procedure TForm1.UpDateMe3Click(Sender: TObject);
begin
// if not DM.UpDateC(http,IP1,IP2,usr,Pwd,FileName) then exit;
if UpdateBad then exit;
ShellExecute(Handle,'Open','EXPLOREr.EXE',pchar(HTTP),nil,SW_NORMAL);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -