📄 upform.pas
字号:
unit Upform;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls,MMSystem, ComCtrls,IniFiles;
Type
TUpNweiss = class(TForm)
Image1: TImage;
Bevel1: TBevel;
Image2: TImage;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
Label1: TLabel;
Edit1: TEdit;
RadioButton2: TRadioButton;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
OpenDialog1: TOpenDialog;
Button2: TButton;
Edit2: TEdit;
Label2: TLabel;
Button1: TButton;
Label3: TLabel;
Button3: TButton;
Label4: TLabel;
GroupBox2: TGroupBox;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
GroupBox3: TGroupBox;
Label5: TLabel;
Edit3: TEdit;
Label6: TLabel;
Edit4: TEdit;
Label7: TLabel;
Edit5: TEdit;
Label8: TLabel;
Edit6: TEdit;
CheckBox4: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
UpDataAddress : String;
UpNweiss: TUpNweiss;
Stkfile :string;
downstkfile :string;
implementation
{$R *.dfm}
uses
Common, Game_Master, GlobalLists,zip,UrlMon,main;
function DownloadFile(Source, Dest: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(source), PChar(Dest), 0, nil) = 0;
except
Result := False;
end;
end;
procedure TUpNweiss.FormCreate(Sender: TObject);
begin
UpNweiss.Caption := 'Nweiss Pro V'+RELEASE_VERSION+' 更新系统';
AppPath := ExtractFilePath(ParamStr(0));
//初始设置
GroupBox3.Visible := False;
GroupBox2.Visible := False;
GroupBox1.Visible := True;
BitBtn1.Caption := '下一步(&N) 〉';
//初始设置
OpenDialog1.FileEditStyle := fsComboBox;
edit1.Text := AppPath + 'Updata\';
downstkfile := edit1.Text;
label4.Caption := '点击 "下一步" 选择升级类型进行升级!'
end;
procedure TUpNweiss.BitBtn3Click(Sender: TObject);
begin
UpNweiss.Hide;
end;
procedure TUpNweiss.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then Stkfile:=OpenDialog1.Files.Strings[0];
edit2.Text := stkfile;
end;
procedure TUpNweiss.RadioButton1Click(Sender: TObject);
begin
label4.Caption := '点击 "下一步" 选择升级类型进行升级!'
end;
procedure TUpNweiss.RadioButton2Click(Sender: TObject);
begin
label4.Caption := '点击 "下一步" 根据选择的Stk文件进行升级!'
end;
procedure TUpNweiss.Button3Click(Sender: TObject);
begin
downstkfile := edit1.Text;
end;
procedure TUpNweiss.BitBtn1Click(Sender: TObject);
var
Str : string; //temp storage for read line.
Txt : TextFile;
UpdataVar : String;
UpdataFile : String;
Upinfo1 :TStringList;
Stkfile1 :Tzip;
begin
Application.ProcessMessages;
Upinfo1 := TStringList.Create;
//Stk文件直接解压 2004年8月29日
if RadioButton2.Checked = True Then Begin
CreateDir(Apppath);
Stkfile1 := tzip.create(Stkfile1);
Stkfile1.Filename := Edit2.Text;
Stkfile1.ExtractPath := AppPath;
Stkfile1.ExtractOptions :=[eoWithPaths];
Stkfile1.Extract;
MessageBox(Handle,'Stk文件升级成功,请按说明结束安装!','Nweiss Pro V'+ RELEASE_VERSION,MB_OK + MB_ICONINFORMATION);
exit;
end;
//Stk文件直接解压 2004年8月29日
//完整升级 2004年8月29日
//判断是否为升级成功
if BitBtn1.Caption = '完成(&R)' Then Begin
if edit6.Text = '成功升级,请把"Nweiss.exe1"改名为"Nweiss.exe" 至此升级成功! ' then Begin
frmMain.Close;
UpNweiss.Close;
end;
end;
if BitBtn1.Caption = '完成(&R)' then UpNweiss.Hide;
//判断是否为升级成功
if GroupBox1.Visible =True Then Begin
GroupBox2.Visible :=True;
GroupBox1.Visible :=False;
BitBtn2.Enabled := True;
exit;
end else begin
if GroupBox2.Visible =True Then Begin
GroupBox3.Visible :=True ;
GroupBox2.Visible :=False;
mkdir(downstkfile);
UpDataAddress :='http://web.sfeng.net/esxgx/ro/Wupdata.txt';
edit4.Text :='V'+RELEASE_VERSION;
DownloadFile(pchar(UpDataAddress),pchar(downstkfile) + 'Wupdata.txt');
//如果没有下载到文件,就说明找不到服务器
if not FileExists(downstkfile + 'Wupdata.txt') then begin
edit6.Text := '更新停止,原因:连接不到服务器. ';
RmDir(downstkfile);
BitBtn1.Caption := '完成(&R)';
exit;
end;
//如果没有下载到文件,就说明找不到服务器
if DownloadFile(pchar(UpDataAddress),pchar(downstkfile) + 'Wupdata.txt') then
assignfile(Txt,downstkfile + 'Wupdata.txt');
reset(txt);
readln(txt,Str);
Upinfo1.Clear;
Upinfo1.DelimitedText :=str;
UpdataVar :=upinfo1.Strings[0];
edit3.Text :=UpdataVar;
UpdataFile := upinfo1.Strings[1];
edit5.Text := UpdataFile;
closefile(txt);
if Edit3.Text = 'V' + RELEASE_VERSION Then
Begin
MessageBox(Handle,'你的版本已经是最新的了!','Nweiss Pro V'+ RELEASE_VERSION,MB_OK + MB_ICONEXCLAMATION);
edit6.Text := '更新停止,原因:版本已经是最新. ';
BitBtn1.Caption := '完成(&R)';
deletefile(downstkfile + 'Wupdata.txt');
RmDir(downstkfile);
exit;
end;
if Edit3.Text = RELEASE_VERSION Then
Begin
MessageBox(Handle,'你的版本已经是最新的了!','Nweiss Pro V'+ RELEASE_VERSION,MB_OK + MB_ICONEXCLAMATION);
edit6.Text := '更新停止,原因:版本已经是最新. ';
BitBtn1.Caption := '完成(&R)';
deletefile(downstkfile + 'Wupdata.txt');
RmDir(downstkfile);
exit;
end;
DownloadFile(pchar(UpdataFile),pchar(downstkfile) + 'Data.stk');
if not FileExists(downstkfile + 'Data.stk') then begin
edit6.Text := '更新停止,原因:Data.stk服务器上没有找到. ';
BitBtn1.Caption := '完成(&R)';
deletefile(downstkfile + 'Wupdata.txt');
RmDir(downstkfile);
end;
if DownloadFile(pchar(UpdataFile),pchar(downstkfile) + 'Data.stk') then Begin
//Stk文件解开
CreateDir(downstkfile);
Stkfile1 := tzip.create(Stkfile1);
Stkfile1.Filename := downstkfile +'Data.stk';
Stkfile1.ExtractPath := AppPath;
Stkfile1.ExtractOptions :=[eoWithPaths];
Stkfile1.Extract;
//Stk文件解开
edit6.Text := '成功升级,请把"Nweiss.exe1"改名为"Nweiss.exe" 至此升级成功! ';
BitBtn1.Caption := '完成(&R)';
BitBtn2.Enabled :=False;
deletefile(downstkfile + 'Wupdata.txt');
if CheckBox4.Checked = False Then Begin
deletefile(downstkfile +'Data.stk');
RmDir(downstkfile);
end else begin
RmDir(downstkfile);
end;
end;
end;
end;
//完整升级 2004年8月29日
end;
procedure TUpNweiss.CheckBox2Click(Sender: TObject);
begin
CheckBox1.Checked :=True;
end;
procedure TUpNweiss.CheckBox3Click(Sender: TObject);
begin
CheckBox1.Checked :=True;
end;
procedure TUpNweiss.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked =false then Begin
CheckBox1.Checked :=false;
CheckBox2.Checked :=false;
CheckBox3.Checked :=false;
end;
end;
procedure TUpNweiss.RadioButton3Click(Sender: TObject);
begin
checkbox1.Enabled :=False;
checkbox2.Enabled :=False;
checkbox3.Enabled :=False;
end;
procedure TUpNweiss.RadioButton4Click(Sender: TObject);
begin
checkbox1.Enabled :=True;
checkbox2.Enabled :=True;
checkbox3.Enabled :=True;
end;
procedure TUpNweiss.BitBtn2Click(Sender: TObject);
begin
if GroupBox2.Visible = True Then Begin
GroupBox3.Visible := False;
GroupBox2.Visible := False;
GroupBox1.Visible := True;
end;
if GroupBox3.Visible = True Then Begin
BitBtn2.Enabled :=False;
end;
if GroupBox1.Visible = True Then Begin
BitBtn2.Enabled :=False;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -