自动更新源代码使用indy.idFTP方式更新。 ( 积分: 1 )

  • 主题发起人 主题发起人 sxper
  • 开始时间 开始时间
S

sxper

Unregistered / Unconfirmed
GUEST, unregistred user!
//写的不好。青各位指教了
有个问题。
1 为什么我从delphi拷贝的中文到别的环境中旧变成乱码呢
2 如果要做成多文件下载的话。怎么解决
、、-----
unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP, ComCtrls,inifiles,shellapi;

type
TForm1 = class(TForm)
IdFTPSun: TIdFTP;
Button1: TButton;
pb: TProgressBar;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Ini: TIniFile;
NewVersion,Newfiles,Version,files :string ;
begin
try
idFTPSun.Host:='127.0.0.1';
idFTPSun.Username:='anonymous';
idFTPSun.Password:='';
idFTPSun.Connect;
idFTPSun.ChangeDir('/update');
idFTPSun.Get('update.ini','temp.ini',true,false);
pb.Position:=10;//½ø¶È¿ØÖÆ
//==================== ger new Version begin
//Ini := TIniFile.Create( 'E:/002.¸öÈËÎļþ/ftp×Ô¶¯¸üгÌÐò/update21.ini' );//±ØÐëÄÇôд¡£²»È»²»³É¹¦Ê§°ÜµÄÓôÃÆ
Ini :=TInifile.Create(ExtractFilePath(Paramstr(0))+'temp.ini'); //±ØÐëÄÇôд¡£²»È»²»³É¹¦Ê§°ÜµÄÓôÃÆ

try
NewVersion := Ini.ReadString( 'data', 'Version', '123' );
Newfiles := Ini.ReadString( 'data', 'file','222' );


finally
Ini.Free;
deleteFile('temp.ini');
end;
//==================== get new Version end
pb.Position:=pb.Position+10;//½ø¶È¿ØÖÆ
//=============== get oldVersion begin

Ini :=TInifile.Create(ExtractFilePath(Paramstr(0))+'update.ini'); //±ØÐëÄÇôд¡£²»È»²»³É¹¦Ê§°ÜµÄÓôÃÆ
showmessage(Ini.FileName);
try
Version := Ini.ReadString( 'data', 'Version', '123' );


finally
Ini.Free;
end;
//==================== get new Version end
pb.Position:=pb.Position+10;//½ø¶È¿ØÖÆ
//=================== compare the files and download begin
if Version<>NewVersion then
begin
showmessage('а汾ºÅ=>'+NewVersion+#13+Newfiles+#13+'¾É°æ±¾ºÅ=>'+Version);
idFTPSun.Get(Newfiles,Newfiles,true,false);
showmessage(idFTPSun.RetrieveCurrentDir);
idFTPSun.Get('update.ini','update.ini',true,false);
showmessage('¸üгɹ¦');
end
else
begin
showmessage('²»ÐèÒª¸üÐÂ');
end;
//=================== compare the files download end=========
pb.Position:=pb.Position+10;//½ø¶È¿ØÖÆ
except
showmessage('²»ÄÜÁ¬½Ó');
end;
pb.Position:=100;//½ø¶È¿ØÖÆ
idFTPSun.Abort; //¶Ï¿ªÁ¬½Ó
idFTPSun.Quit; //Í˳öÁ¬½Ó

//ShellExecute(Application,'OPEN','Project11.exe',NULL,NULL,SW_SHOW);
ShellExecute(0,'open', 'Project11.exe', nil, nil, SW_SHOWNORMAL);
application.Terminate;

end;

end.
 
//写的不好。青各位指教了
有个问题。
1 为什么我从delphi拷贝的中文到别的环境中旧变成乱码呢
2 如果要做成多文件下载的话。怎么解决
、、-----
unit main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP, ComCtrls,inifiles,shellapi;

type
TForm1 = class(TForm)
IdFTPSun: TIdFTP;
Button1: TButton;
pb: TProgressBar;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Ini: TIniFile;
NewVersion,Newfiles,Version,files :string ;
begin
try
idFTPSun.Host:='127.0.0.1';
idFTPSun.Username:='anonymous';
idFTPSun.Password:='';
idFTPSun.Connect;
idFTPSun.ChangeDir('/update');
idFTPSun.Get('update.ini','temp.ini',true,false);
pb.Position:=10;//½ø¶È¿ØÖÆ
//==================== ger new Version begin
//Ini := TIniFile.Create( 'E:/002.¸öÈËÎļþ/ftp×Ô¶¯¸üгÌÐò/update21.ini' );//±ØÐëÄÇôд¡£²»È»²»³É¹¦Ê§°ÜµÄÓôÃÆ
Ini :=TInifile.Create(ExtractFilePath(Paramstr(0))+'temp.ini'); //±ØÐëÄÇôд¡£²»È»²»³É¹¦Ê§°ÜµÄÓôÃÆ

try
NewVersion := Ini.ReadString( 'data', 'Version', '123' );
Newfiles := Ini.ReadString( 'data', 'file','222' );


finally
Ini.Free;
deleteFile('temp.ini');
end;
//==================== get new Version end
pb.Position:=pb.Position+10;//½ø¶È¿ØÖÆ
//=============== get oldVersion begin

Ini :=TInifile.Create(ExtractFilePath(Paramstr(0))+'update.ini'); //±ØÐëÄÇôд¡£²»È»²»³É¹¦Ê§°ÜµÄÓôÃÆ
showmessage(Ini.FileName);
try
Version := Ini.ReadString( 'data', 'Version', '123' );


finally
Ini.Free;
end;
//==================== get new Version end
pb.Position:=pb.Position+10;//½ø¶È¿ØÖÆ
//=================== compare the files and download begin
if Version<>NewVersion then
begin
showmessage('а汾ºÅ=>'+NewVersion+#13+Newfiles+#13+'¾É°æ±¾ºÅ=>'+Version);
idFTPSun.Get(Newfiles,Newfiles,true,false);
showmessage(idFTPSun.RetrieveCurrentDir);
idFTPSun.Get('update.ini','update.ini',true,false);
showmessage('¸üгɹ¦');
end
else
begin
showmessage('²»ÐèÒª¸üÐÂ');
end;
//=================== compare the files download end=========
pb.Position:=pb.Position+10;//½ø¶È¿ØÖÆ
except
showmessage('²»ÄÜÁ¬½Ó');
end;
pb.Position:=100;//½ø¶È¿ØÖÆ
idFTPSun.Abort; //¶Ï¿ªÁ¬½Ó
idFTPSun.Quit; //Í˳öÁ¬½Ó

//ShellExecute(Application,'OPEN','Project11.exe',NULL,NULL,SW_SHOW);
ShellExecute(0,'open', 'Project11.exe', nil, nil, SW_SHOWNORMAL);
application.Terminate;

end;

end.
 
后退
顶部