asp 我不会,delphi 我会
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,mshtml, OleCtrls, SHDocVw, ExtCtrls, StdCtrls,winsock, Sockets,
IdBaseComponent, IdComponent, IdIPWatch;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Memo1: TMemo;
TcpServer1: TTcpServer;
IdIPWatch1: TIdIPWatch;
procedure FormShow(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
begin
webbrowser1.Navigate('http://www.ip138.com/ip2city.asp');//这个网址是关键,
//本人因为对网络不懂,分析了好长时间才彻悟出这个地址 ,尤其是后面的那个 ip2city.asp
with form1 do
begin
width:=0;
height:=0;
end;
end;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var str1,str:string;
i:integer;
begin
str1:=IHtmlDocument2(WebBrowser1.Document).Body.OuterText;
str:=str1;
i:=pos('[',str);
str:= copy(str,i+1,20); //去掉前面的部分
i:=pos(']',str);
str:=copy(str,0,i-1); //去掉后面的部分
memo1.Lines.Add(str);
//把ip地址已经单独拿出来了
memo1.lines.add('主机名: '+idipwatch1.LocalName);
memo1.lines.add('内网ip: '+idipwatch1.localip);
if pos('您的IP地址',str1)>0 then
begin
i:= application.MessageBox(pansichar('主机名是: '+idipwatch1.LocalName+#10+'公网ip是: '+str+#10+'内网ip是: '+idipwatch1.localip),'提示',0)
end
else
i:= application.MessageBox(pansichar('主机名是: '+idipwatch1.LocalName+#10+'内网ip是: '+idipwatch1.localip),'提示',0) ;
if i=1 then
application.Terminate ;
end;
end.
参考答案 28."他把他的整个生命的重量都压到了我的身上,我承受不了" 我悲伤的对顾里说.