MyStream:=TMemoryStream.Create;
try IdHTTP1.Get('http://geis.onlinedown.net/down/98wb.exe',MyStream); except//INDY控件一般要使用这种try..except结构.
Application.MessageBox('网络出错未能下载完成!', '系统提示', MB_OK + MB_ICONERROR);
MyStream.Free;
Exit;
end;
filepath:=ExtractFilePath(ParamStr(0));
MyStream.SaveToFile(filepath+'\DownLoadFiles\98wb.exe');
MyStream.Free;
Application.MessageBox('下载完成!','系统提示',0);这里是我一个下载的代码,请问怎么能把这些代码放在一个线程里面去执行。希望各位不吝赐教
try IdHTTP1.Get('http://geis.onlinedown.net/down/98wb.exe',MyStream); except//INDY控件一般要使用这种try..except结构.
Application.MessageBox('网络出错未能下载完成!', '系统提示', MB_OK + MB_ICONERROR);
MyStream.Free;
Exit;
end;
filepath:=ExtractFilePath(ParamStr(0));
MyStream.SaveToFile(filepath+'\DownLoadFiles\98wb.exe');
MyStream.Free;
Application.MessageBox('下载完成!','系统提示',0);这里是我一个下载的代码,请问怎么能把这些代码放在一个线程里面去执行。希望各位不吝赐教
是什么意思?
我没看懂能不能说的具体点
还是现在用delphi的人非常少了
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms;type
TMyThread = class(TThread)
private
procedure DW;
protected
procedure Execute; override;
end; TFrmMain = class(TForm)
MainMenu1: TMainMenu;
...
var
FrmMain: TFrmMain;implementation
...
...{ TInitThread }procedure TMyThread.DW;
begin
MyStream:=TMemoryStream.Create;
try IdHTTP1.Get('http://geis.onlinedown.net/down/98wb.exe',MyStream); except//INDY控件一般要使用这种try..except结构.
Application.MessageBox('网络出错未能下载完成!', '系统提示', MB_OK + MB_ICONERROR);
MyStream.Free;
Exit;
end;
filepath:=ExtractFilePath(ParamStr(0));
MyStream.SaveToFile(filepath+'\DownLoadFiles\98wb.exe');
MyStream.Free;
Application.MessageBox('下载完成!','系统提示',0);
end;
procedure TInitThread.Execute;
begin
FreeOnTermiNate:=True;
Synchronize(DW);
end;...
end.