function TForm1.DownLoadUpdater(AUrl, Outputfilename : string): Boolean;
var
idHttp : TIdHTTP;
dStream: TFileStream;
begin
Result := True;
try
dStream := TFileStream.Create(ExtractFilePath(Application.ExeName) + OutputFileName, fmCreate or fmShareExclusive);
예전에 어떤분이 답변하신 내용인데, 아래 코드를 참고하세요..
폼에다가 idhttp하고 progress, button를 하나씩 올리신다음에..
// function downloadupdater를 만들어주시고...
function TForm1.DownLoadUpdater(AUrl, Outputfilename : string): Boolean;
var
idHttp : TIdHTTP;
dStream: TFileStream;
begin
Result := True;
try
dStream := TFileStream.Create(ExtractFilePath(Application.ExeName) + OutputFileName, fmCreate or fmShareExclusive);
ProgressBar1.Position := 0;
bytesRead := 0;
idhttp1.Head(AUrl);
ProgressBar1.max := idhttp1.response.ContentLength;
idHTTP1.Get(AUrl, dStream);
Application.ProcessMessages;
dStream.Free;
except
Result := False;
end;
end;
// idhttp의 이벤트 핸들로의 onwork에 작성해주세요.
procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
if (AWorkMode = wmRead) then
begin
bytesRead := bytesRead + AWorkCount;
ProgressBar1.position := bytesRead;
end;
end;
// 사용하실때에는...
procedure TForm1.Button1Click(Sender: TObject);
begin
DownLoadUpdater('http://xxxx.co.kr/delphi.exe','delphi.exe')
end;