1 2 //this is an exmaple to show your IP address from a website called 3 //www.whatismyip.com and display the results in Edit box 4 //--------------------------------------------------------------------------- 5 6 #include <vcl.h> 7 #pragma hdrstop 8 9 #include "Unit1.h" 10 //--------------------------------------------------------------------------- 11 #pragma package(smart_init) 12 #pragma resource "*.dfm" 13 TForm1 *Form1; 14 //--------------------------------------------------------------------------- 15 __fastcall TForm1::TForm1(TComponent* Owner) 16 : TForm(Owner) 17 { 18 } 19 //--------------------------------------------------------------------------- 20 21 void __fastcall TForm1::Button1Click(TObject *Sender) 22 { 23 TNMHTTP *http = new TNMHTTP(this); 24 //leave the line below alone 25 http->Get("http://www.whatismyip.com"); 26 27 int t = http->Body.AnsiPos("Your IP Is")+11; 28 int l=t; 29 while (http->Body.SubString(l,1)!=" ") l++; 30 Edit1->Text = http->Body.SubString(t,l-t); 31 32 delete http; 33 } 34 //---------------------------------------------------------------------------