Да спосибо подумаю.
Вот код он так тестовый но зато работает и спроверкой правда неудобный.
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,URLMon, ShellApi, StdCtrls, Gauges, wininet;
type TFormDownload = class(TForm) Button1: TButton; Label1: TLabel; Button2: TButton; Label2: TLabel; function DownloadFile(SourceFile, DestFile: string): Boolean; function GetUrlInfo(const dwInfoLevel: DWORD; const FileURL: string):string; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); function Download: boolean; private { Private declarations } public { Public declarations } end;
var FormDownload: TFormDownload;
implementation
{$R *.dfm}
function TFormDownload.DownloadFile(SourceFile, DestFile: string): Boolean; begin try Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0; except Result := False; end; end;
function TFormDownload.GetUrlInfo(const dwInfoLevel: DWORD; const FileURL: string):string; var hSession, hFile: hInternet; dwBuffer: Pointer; dwBufferLen, dwIndex: DWORD; begin Result := ''; hSession := InternetOpen('STEROID Download', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); if Assigned(hSession) then begin hFile := InternetOpenURL(hSession, PChar(FileURL), nil, 0, INTERNET_FLAG_RELOAD, 0); dwIndex := 0; dwBufferLen := 20; if HttpQueryInfo(hFile, dwInfoLevel, @dwBuffer, dwBufferLen, dwIndex) then Result := PChar(@dwBuffer); if Assigned(hFile) then InternetCloseHandle(hFile); InternetCloseHandle(hsession); end; end;
procedure TFormDownload.Button1Click(Sender: TObject); const SourceFile = 'http://calculator2006.narod.ru/txt.rar'; DestFile = '\txt.rar'; var S:String; begin if Download then begin if DownloadFile(SourceFile, DestFile) then begin // ShowMessage('Âû õîòèòå çàãðóçèòü ôàèë txt.rar'+' '+S+' '+'Áàéò'); ShellExecute(Application.Handle, PChar('open'), PChar(DestFile),PChar(''), nil, SW_NORMAL); end else ShowMessage('Error while downloading ' + SourceFile) end end;
function TFormDownload.Download; begin // end;
procedure TFormDownload.Button2Click(Sender: TObject); var F : textfile; S,Text1:String; begin AssignFile(F,'Download.ini'); Reset(F); Read(F,Text1); if Text1='' then begin CloseFile(F); AssignFile(F,'Download.ini'); Rewrite(F); S:=GetUrlInfo(HTTP_QUERY_CONTENT_LENGTH, 'http://calculator2006.narod.ru/txt.rar'); Write(F,S); Label1.Caption:=S; Label2.Caption:='Çàãðóçèòü ôàèë'; Button1.Visible:=True; CloseFile(F); end else begin S:=GetUrlInfo(HTTP_QUERY_CONTENT_LENGTH, 'http://calculator2006.narod.ru/calculator.rar'); if StrToInt(S)>StrToInt(Text1) then begin CloseFile(F); AssignFile(F,'Download.ini'); Rewrite(F); Write(F,S); label1.Caption:='Ðàçìåð'+' '+S; Label2.Caption:='Çàãðóçèòü ôàèë'; Button1.Visible:=True; CloseFile(F); end else begin Label2.Caption:='Óâàñ ïîñëåäíÿÿ âåðñèÿ'; Label1.Caption:=GetUrlInfo(HTTP_QUERY_CONTENT_LENGTH, 'http://calculator2006.narod.ru/calculator.rar'); end; end; end; end.
|
А поповоду Indi можеш поподробнее |