Created
March 10, 2020 09:06
-
-
Save HemulGM/cc86529315ede9e4ce03ebab9cddeabf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit Unit3; | |
interface | |
uses | |
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, | |
System.Classes, System.Types, Vcl.Graphics, Vcl.Controls, Vcl.Forms, | |
Vcl.Dialogs, System.Net.HttpClient, Vcl.StdCtrls; | |
type | |
TForm3 = class(TForm) | |
Memo1: TMemo; | |
Button1: TButton; | |
procedure Button1Click(Sender: TObject); | |
private | |
procedure OnReceiveData(const Sender: TObject; AContentLength, AReadCount: Int64; var Abort: Boolean); | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
Form3: TForm3; | |
implementation | |
{$R *.dfm} | |
procedure TForm3.OnReceiveData(const Sender: TObject; AContentLength: Int64; AReadCount: Int64; var Abort: Boolean); | |
begin | |
Memo1.Lines.Add(Round(100 / AContentLength * AReadCount).ToString + '%'); | |
Application.ProcessMessages; | |
end; | |
procedure TForm3.Button1Click(Sender: TObject); | |
var | |
HTTP: THTTPClient; | |
FS: TFileStream; | |
Url: string; | |
begin | |
FileClose(FileCreate('D:\tmp\file.tmp')); | |
FS := TFileStream.Create('D:\tmp\file.tmp', fmOpenReadWrite); | |
Url := 'https://vk.com/doc-51529633_233391193?dl=985345b6c76e14d803'; | |
HTTP := THTTPClient.Create; | |
HTTP.OnReceiveData := OnReceiveData; | |
HTTP.Get(Url, FS); | |
FS.Free; | |
HTTP.Free; | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment