貝殼兒的寶貝匣子

有一天,可愛的小狗狗問媽媽:幸福是什麼? 狗媽媽說:幸福其實就是你的尾巴. 小狗狗拼命咬自己的尾巴,但是它都咬不到 "媽媽,為什麼我抓不住我的幸福?" "傻孩子,抬起頭去走,幸福就會跟著你的!"
posts - 7, comments - 1, trackbacks - 0, articles - 0
  IT博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

獲得本地電腦IP的函數

Posted on 2005-11-14 08:55 貝殼兒 阅读(218) 评论(0)  编辑 收藏 引用 所属分类: Delphi编程
function GetIP:String;
var
WSData: TWSAData;
Buffer: array[0..63] of Char;
HostEnt: PHostEnt;
PPInAddr: ^PInAddr;
IPString: String;
begin
IPString:='\';
try
  WSAStartUp($101, WSData);
  GetHostName(Buffer, SizeOf(Buffer));
  HostEnt:=GetHostByName(Buffer);
  if Assigned(HostEnt) then
  begin
   PPInAddr:=@(PInAddr(HostEnt.H_Addr_List^));
   while Assigned(PPInAddr^) do
   begin
    IPString:=StrPas(INet_NToA(PPInAddr^^));
    Inc(PPInAddr);
   end;
  end;
  Result := IPString;
finally
  try
   WSACleanUp;
  except
  end;
end;
end;
只有注册用户登录后才能发表评论。