unit Unit1;
interface
uses
Windows, COMobj, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
strURL: String;
objHTTP: OleVariant;
begin
objHttp := CreateOleObject('WinHttp.WinHttpRequest.5.1');
try
strURL := 'http://automation.whatismyip.com/n09230945.asp';
//Send request To URL
objHTTP.Open('POST', strURL, False);
try
objHTTP.Send(Memo1.Lines.Text); Memo1.Lines.Text := objHTTP.ResponseText
except
on e: Exception do
MessageDlg('Error Occured: '+e.Message, mtError, [mbOK], 0);
end
finally
objHttp := Unassigned;
end;
end;
end.
Source
comments