Teşekürler
Kod: Tümünü seç
procedure TGuncelleme.Button1Click(Sender: TObject);begin
Guncelle();
end;
Var
xDosyaUzunluk : LongInt;
function FTPDosyaAl( IdFTP : TIdFTP; SrcDosya, DesDosya:TFileName; Ftp, RemoteDir, Login, Pass : String ):Boolean;
begin // Uses IdFTP, IdFTPCommon
Result := False;
IdFtp.Host := Ftp;
IdFtp.Username := Login;
IdFtp.Password := Pass;
IdFtp.Passive := True;
IdFtp.Connect;
If IdFtp.Connected then
begin
IdFtp.ChangeDir(RemoteDir);
// Gauge'de kullanmak için
// Dosya Uzunluğunu grlobal bir değişkene atıyoruz...
xDosyaUzunluk := IdFtp.Size( SrcDosya );
Try
IdFtp.TransferType := ftBinary; // Uses IdFTPCommon
IdFtp.Get(SrcDosya, DesDosya, True);
Finally
Result := True;
end;
IdFtp.Quit;
end;
end;
procedure TGuncelleme.FormCreate(Sender: TObject);
begin
If FileExists(ExtractFilePath(Application.Exename) +'Guncelle.BAT')
then DeleteFile(ExtractFilePath(Application.Exename) +'Guncelle.BAT');
end;
procedure TGuncelleme.Guncelle();
Var
FTPAdres,
KaynakDizin,
Name,
Pass,
KaynakDosya,
HedefDosya : String;
begin
FTPAdres := 'ftp://s182.turbobit.net';
KaynakDizin := '/httpdocs';
Name := 'kullaniciadi@gmail.com';
Pass := '**********';
KaynakDosya := 'Kaynak.exe';
HedefDosya := ChangeFileExt( ExtractFilePath(Application.Exename) + KaynakDosya, '.exe' );
If FileExists(HedefDosya) AND ( MessageDlg('Bu dosya zaten inmiş durumda, tekrar indirilsin mi ? '+#13'('+HedefDosya+')', mtInformation, [mbYes, mbCancel], 0) = mrCancel )
then EXIT
else DeleteFile(HedefDosya);
If FTPDosyaAl( IdFtp, KaynakDosya, HedefDosya, FTPAdres, KaynakDizin, Name, Pass )
then AdvSmoothMessageDialog1.Execute
else MessageDlg('Dosya Bulunamadı - Dosya Silinmiş Olabilir'+#13'('+KaynakDosya+')', mtError, [mbok], 0);
With TStringList.Create do begin
Add('@Echo Off' );
Add( Format('Copy %s %s', [ChangeFileExt(Application.ExeName,'.exe'), Application.ExeName]) );
Add('DEL '+ChangeFileExt(Application.ExeName,'.BAK'));
Add( Application.ExeName );
Free;
end;
Application.Terminate;
WinExec( PChar( ExtractFilePath(Application.Exename)+'Guncelle.BAT'), SW_Hide );
end;
procedure TGuncelleme.IdFtpStatus(ASender: TObject; const AStatus: TIdStatus;
const AStatusText: string);
begin
StatusBar1.SimpleCaption := AStatusText;
end;
procedure TGuncelleme.IdFtpWork(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Integer);
begin
Gauge1.Position := AWorkCount;
Application.ProcessMessages;
end;
procedure TGuncelleme.IdFtpWorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Integer);
begin
Gauge1.Minimum := 0;
Gauge1.Maximum:= xDosyaUzunluk;
Gauge1.Position := 0;
Gauge1.Visible := True;
end;
procedure TGuncelleme.IdFtpWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
begin
Gauge1.Position := 0;
Gauge1.Visible := False;
end;
procedure TGuncelleme.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ShellExecute(Handle, 'open',
pchar(extractfilepath(application.exename)+'Ekonomi.exe'),
nil,
nil,
sw_ShowNormal);
end;