unit jyb;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdHTTP, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    IdHTTP1: TIdHTTP;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
 tmpStream:TFileStream;
begin
   tmpStream:=TFileStream.Create('c:\aa.zip',fmCreate);
 try
   idhttp1.Get('http://192.168.2.143:7001/z.zip',tmpStream);
 finally
   tmpStream.Free;
 end;
end;
end.
转变成Console Application,高手请指教!

解决方案 »

  1.   

    试试这样:program MyProject;{$APPTYPE CONSOLE}uses
      Windows, Messages, SysUtils, Variants, Classes,  Controls, Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
      IdHTTP, StdCtrls;
    procedure fun();
    var
     tmpStream:TFileStream;
     idHttp1:TIDhttp;
    begin
       idHttp1:=TIDHttp.Create(Application);
       tmpStream:=TFileStream.Create('c:\aa.zip',fmCreate);
     try
       idhttp1.Get('http://192.168.2.143:7001/z.zip',tmpStream);
     finally
       tmpStream.Free;
       idHttp1.Free;
     end;
    end;
    begin
       fun();
    end.
      

  2.   

    idHttp1:=TIDHttp.Create(Application);此语句中Application指的是什么?
      

  3.   

    是代表当前的工程;
    Application的属性就是工程的属性;
    在某种意义上讲和最终的exe是一样的。你实验一下,这两个语句就能知道什么是Application,同时也知道什么是MainForm了。ShowWindow(Application.Handle, SW_HIDE);ShowWindow(Form1.Handle, SW_HIDE);
      

  4.   

    我是新手,所以还是不太明白,就是说
      ShowWindow(Application.Handle, SW_HIDE);  ShowWindow(Form1.Handle, SW_HIDE);
    怎么执行啊?上边的程序应该怎样设置Application啊?
    idHttp1怎么初始化啊?谢谢谢谢!
      

  5.   

    现在不知道最终的exe文件名,怎么办?