unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;type
TForm1 = class(TForm)
edt1: TEdit;
edt2: TEdit;
btn1: TButton;
idhtp1: TIdHTTP;
procedure FormCreate(Sender: TObject);
procedure Down(url,save:string);
procedure btn1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations } end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
url,save:string;
begin
url:=edt1.Text;
save:=edt2.Text;
BeginThread(nil,0,@Form1.Down(url,save),nil,0,nil)
end;procedure TForm1.Down(url,save:string);
var
MyStream:TMemoryStream;
begin
MyStream:=TMemoryStream.Create;
idhtp1.Get(url,MyStream);
MyStream.SaveToFile(save);
MyStream.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edt1.Text:='http://down.sandai.net/mini/ThunderMiniInstall.exe';
edt2.Text:='D:\test.exe';
end;end.报错信息:
Compiling Project1.dproj (Debug configuration)
[DCC Error] Unit1.pas(39): E2036 Variable required
[DCC Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'
Failed
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;type
TForm1 = class(TForm)
edt1: TEdit;
edt2: TEdit;
btn1: TButton;
idhtp1: TIdHTTP;
procedure FormCreate(Sender: TObject);
procedure Down(url,save:string);
procedure btn1Click(Sender: TObject); private
{ Private declarations }
public
{ Public declarations } end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
url,save:string;
begin
url:=edt1.Text;
save:=edt2.Text;
BeginThread(nil,0,@Form1.Down(url,save),nil,0,nil)
end;procedure TForm1.Down(url,save:string);
var
MyStream:TMemoryStream;
begin
MyStream:=TMemoryStream.Create;
idhtp1.Get(url,MyStream);
MyStream.SaveToFile(save);
MyStream.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edt1.Text:='http://down.sandai.net/mini/ThunderMiniInstall.exe';
edt2.Text:='D:\test.exe';
end;end.报错信息:
Compiling Project1.dproj (Debug configuration)
[DCC Error] Unit1.pas(39): E2036 Variable required
[DCC Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'
Failed
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;type
TForm1 = class(TForm)
edt1: TEdit;
edt2: TEdit;
btn1: TButton;
idhtp1: TIdHTTP;
procedure FormCreate(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}function Down(p: pointer): boolean; stdcall;
var
MyStream:TMemoryStream;
begin
MyStream:=TMemoryStream.Create;
Form1.idhtp1.Get(edt1.Text,MyStream);
MyStream.SaveToFile(Form1.edt2.Text);
MyStream.Free;
Result:= true;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
edt1.Text:='http://down.sandai.net/mini/ThunderMiniInstall.exe';
edt2.Text:='D:\test.exe';
end;procedure TForm1.btn1Click(Sender: TObject);
begin
BeginThread(nil,0,@Down,nil,0,nil)
end;end.