Einzelnen Beitrag anzeigen

Daniel B
(Gast)

n/a Beiträge
 
#4

Re: Internet IP herausfinden...

  Alt 6. Nov 2003, 16:11
uses ..., WinSock;
Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);

  function GetIPAddress: String;
  var
    PHoste: PHostEnt;
    Buffer: array [0..100] of Char;
    WSAData: TWSADATA;
  begin
    Result := '';
    if WSAStartup($0101, WSAData) <> 0 then
      Exit;
    GetHostName(Buffer, SizeOf(Buffer));
    PHoste := GetHostByName(buffer);
    if phoste = nil then
      Result := '127.0.0.1'
    else
      Result := StrPas(Inet_NToa(PInAddr(phoste^.h_addr_list^)^));
    WSACleanup;
  end;

begin
  ShowMessage(GetIPAddress);
end;
  Mit Zitat antworten Zitat