Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi IP Adresse ermitteln (https://www.delphipraxis.net/9610-ip-adresse-ermitteln.html)

Langohr 30. Sep 2003 09:48


IP Adresse ermitteln
 
Hallo DP ' ler !

Ich hoffe ihr könnt mir helfen.
Ich möchte gerne die eigene IP- Adresse im Netzwerk herausbekommen.

PS: Wenn möglich, ohne die Indy- Komponenten.

Vielen Dank im Vorraus !

Luckie 30. Sep 2003 09:52

Re: IP Adresse ermitteln
 
Hilft das Hier im Forum suchenip-adresse netzwerk eventuell?

Gollum 30. Sep 2003 10:19

Re: IP Adresse ermitteln
 
Hallo,

hier eine der Möglichkeiten:

Delphi-Quellcode:
uses
  WinSock;

function IPAdress:String;
const
  sTxtIP = '%d.%d.%d.%d';
var
  rSockVer  : Word;
  aWSAData  : TWSAData;
  szHostName : array[0..255] of Char;
  pHE       : PHostEnt;
begin
  Result:='';
  // WinSock Version 1.1 initialisieren
  rSockVer:=MakeWord(1, 1);
  WSAStartup(rSockVer, aWSAData );
  try
    FillChar(szHostName, SizeOf(szHostName), #0);
    GetHostName(szHostName, SizeOf(szHostName));
    pHE:=GetHostByName(szHostName);
    if (pHE<>nil) then with pHE^ do
      Result:=Format(sTxtIP,
                [Byte(h_addr^[0]), Byte(h_addr^[1]),
                 Byte(h_addr^[2]), Byte(h_addr^[3])]);
  finally
    WSACleanup;
  end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:37 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz