unit1.pas.~1~

来自「Delphi 2005程序设计教程_实例源文件和教学课件」· ~1~ 代码 · 共 81 行

~1~
81
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, System.ComponentModel, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdHTTP;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Memo1: TMemo;
    IdHTTP1: TIdHTTP;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    ComboBox3: TComboBox;
    Label3: TLabel;
    procedure ComboBox2Change(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation


{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  source:TMemoryStream;
  response:TStringStream;
begin
  if Combobox1.Items.IndexOf(ComboBox1.text)=-1 then
    ComboBox1.Items.Add(ComboBox1.Text);
  try
    Memo1.Clear ;
    case ComboBox3.ItemIndex of
    0:
      Begin
        IdHTTP1.Head(ComboBox1.Text);
        Memo1.Lines.Add('Content-Type:'+IdHTTP1.Response.ContentType);
        Memo1.Lines.Add('Date:'+DateToStr(IdHTTP1.Response.Date));
      end;
    1: 
      Begin
        Memo1.Lines.Text:=ComboBox1.Text;
      end;
    end;
  finally
    IdHTTP1.Free;
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  try
    ComboBox1.Items.SaveToFile(ExtractFilePath(ParamStr(0))+'url.dat');
  except
  end;
end;

procedure TForm1.ComboBox2Change(Sender: TObject);
begin
  case ComboBox2.ItemIndex of
    0: IdHTTP1.ProtocolVersion :=pv1_0;
    1: IdHTTP1.ProtocolVersion :=pv1_1;
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?