<% dim ModuleName,InfoID,ChannelShortName,CorrelativeArticle,InstallDir,ChannelDir,Keyword,PageTitle,ArticleIntro,Articlecontent Keyword=stripHTML("学Delphi,方法") PageTitle=stripHTML("delphi获取Ip") ArticleIntro=stripHTML("") Articlecontent=stripHTML("procedure TForm1.Button1Click(Sender: TObject);var   aName: array[0..100] of cha…") ModuleName = stripHTML("programme") InfoID = stripHTML("113280") ChannelShortName=stripHTML("编程") InstallDir=stripHTML("http://www.77169.com/") ChannelDir=stripHTML("programme") %> delphi获取Ip - 华盟网 - http://www.77169.com
您现在的位置: 华盟网 >> 编程 >> Delphi >> 正文

delphi获取Ip

2011/12/9 作者:不详 来源: 51CTO博文
导读 <% if len(ArticleIntro)<3 then Response.Write Articlecontent 'Response.Write "Articlecontent" else Response.Write ArticleIntro 'Response.Write "ArticleIntro" end if %>
procedure TForm1.Button1Click(Sender: TObject);
var
   aName: array[0..100] of char;
   WSData: Twsadata;
   a1, a2, a3, a4: byte;
   p: PHostEnt;
   Comput,
   ip: String;
begin
  WSAStartup(1,WSData);
  try
     GetHostName(aName,   100);
     p:=GetHostByName(aName);
     Char(a1):=p.h_addr_List^[0];
     Char(a2):=p.h_addr_List^[1];
     Char(a3):=p.h_addr_List^[2];
     Char(a4):=p.h_addr_List^[3];
  finally
     WSACleanup;
  end;
  Comput:=string(aName);  {计算机名}
  IP:=IntToStr(a1)+'.'+IntToStr(a2)+'.'+IntToStr(a3)+'.'+IntToStr(a4);
  Label1.Caption := ip;
end;


  • 上一篇编程:

  • 下一篇编程: