자신의 ip 알아내기

Delphi 2009. 4. 18. 19:30




function GetMyIP: String;
var
  pHostInfo: pHostEnt;
  pszHostName: array [0..40] of Char;
  IpStr: String;
  i: Integer;

begin
  Result:='';

  GetHostName(pszHostName, 40);
  pHostInfo:=GetHostByName(pszHostName);
 
  // IP 주소를 문자열로 가공
  for i:=0 to 3 do begin
    if
i>0 then IpStr:=IpStr+'.';
    IpStr:=IpStr+IntToStr(Ord(pHostInfo.h_addr_list^[i]));
  end;
 
  if Assigned(pHostInfo) then Result:=IpStr;
end;





Posted by bloodguy
,