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('&ETH;&Acirc;°&aelig;±&frac34;&ordm;&Aring;=>'+NewVersion+#13+Newfiles+#13+'&frac34;&Eacute;°&aelig;±&frac34;&ordm;&Aring;=>'+Version);
idFTPSun.Get(Newfiles,Newfiles,true,false);
showmessage(idFTPSun.RetrieveCurrentDir);
idFTPSun.Get('update.ini','update.ini',true,false);
showmessage('&cedil;ü&ETH;&Acirc;&sup3;&Eacute;&sup1;&brvbar;');
end
else
begin
showmessage('&sup2;&raquo;&ETH;è&Ograve;&ordf;&cedil;ü&ETH;&Acirc;');
end;
//=================== compare the files download end=========
pb.Position:=pb.Position+10;//&frac12;&oslash;&para;&Egrave;&iquest;&Oslash;&Ouml;&AElig;
except
showmessage('&sup2;&raquo;&Auml;&Uuml;&Aacute;&not;&frac12;&Oacute;');
end;
pb.Position:=100;//&frac12;&oslash;&para;&Egrave;&iquest;&Oslash;&Ouml;&AElig;
idFTPSun.Abort; //&para;&Iuml;&iquest;&ordf;&Aacute;&not;&frac12;&Oacute;
idFTPSun.Quit; //&Iacute;&Euml;&sup3;&ouml;&Aacute;&not;&frac12;&Oacute;
//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;//&frac12;&oslash;&para;&Egrave;&iquest;&Oslash;&Ouml;&AElig;
//==================== ger new Version begin
//Ini := TIniFile.Create( 'E:/002.&cedil;&ouml;&Egrave;&Euml;&Icirc;&Auml;&frac14;&thorn;/ftp×&Ocirc;&para;&macr;&cedil;ü&ETH;&Acirc;&sup3;&Igrave;&ETH;ò/update21.ini' );//±&Oslash;&ETH;&euml;&Auml;&Ccedil;&Atilde;&acute;&ETH;&acute;&iexcl;&pound;&sup2;&raquo;&Egrave;&raquo;&sup2;&raquo;&sup3;&Eacute;&sup1;&brvbar;&Ecirc;§°&Uuml;&micro;&Auml;&Oacute;&ocirc;&Atilde;&AElig;
Ini :=TInifile.Create(ExtractFilePath(Paramstr(0))+'temp.ini'); //±&Oslash;&ETH;&euml;&Auml;&Ccedil;&Atilde;&acute;&ETH;&acute;&iexcl;&pound;&sup2;&raquo;&Egrave;&raquo;&sup2;&raquo;&sup3;&Eacute;&sup1;&brvbar;&Ecirc;§°&Uuml;&micro;&Auml;&Oacute;&ocirc;&Atilde;&AElig;
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;//&frac12;&oslash;&para;&Egrave;&iquest;&Oslash;&Ouml;&AElig;
//=============== get oldVersion begin
Ini :=TInifile.Create(ExtractFilePath(Paramstr(0))+'update.ini'); //±&Oslash;&ETH;&euml;&Auml;&Ccedil;&Atilde;&acute;&ETH;&acute;&iexcl;&pound;&sup2;&raquo;&Egrave;&raquo;&sup2;&raquo;&sup3;&Eacute;&sup1;&brvbar;&Ecirc;§°&Uuml;&micro;&Auml;&Oacute;&ocirc;&Atilde;&AElig;
showmessage(Ini.FileName);
try
Version := Ini.ReadString( 'data', 'Version', '123' );
finally
Ini.Free;
end;
//==================== get new Version end
pb.Position:=pb.Position+10;//&frac12;&oslash;&para;&Egrave;&iquest;&Oslash;&Ouml;&AElig;
//=================== compare the files and download begin
if Version<>NewVersion then
begin
showmessage('&ETH;&Acirc;°&aelig;±&frac34;&ordm;&Aring;=>'+NewVersion+#13+Newfiles+#13+'&frac34;&Eacute;°&aelig;±&frac34;&ordm;&Aring;=>'+Version);
idFTPSun.Get(Newfiles,Newfiles,true,false);
showmessage(idFTPSun.RetrieveCurrentDir);
idFTPSun.Get('update.ini','update.ini',true,false);
showmessage('&cedil;ü&ETH;&Acirc;&sup3;&Eacute;&sup1;&brvbar;');
end
else
begin
showmessage('&sup2;&raquo;&ETH;è&Ograve;&ordf;&cedil;ü&ETH;&Acirc;');
end;
//=================== compare the files download end=========
pb.Position:=pb.Position+10;//&frac12;&oslash;&para;&Egrave;&iquest;&Oslash;&Ouml;&AElig;
except
showmessage('&sup2;&raquo;&Auml;&Uuml;&Aacute;&not;&frac12;&Oacute;');
end;
pb.Position:=100;//&frac12;&oslash;&para;&Egrave;&iquest;&Oslash;&Ouml;&AElig;
idFTPSun.Abort; //&para;&Iuml;&iquest;&ordf;&Aacute;&not;&frac12;&Oacute;
idFTPSun.Quit; //&Iacute;&Euml;&sup3;&ouml;&Aacute;&not;&frac12;&Oacute;
//ShellExecute(Application,'OPEN','Project11.exe',NULL,NULL,SW_SHOW);
ShellExecute(0,'open', 'Project11.exe', nil, nil, SW_SHOWNORMAL);
application.Terminate;
end;
end.