Thema: Delphi Netzwerk mit Delphi

Einzelnen Beitrag anzeigen

Benutzerbild von Salomon
Salomon

Registriert seit: 9. Jun 2002
453 Beiträge
 
#25
  Alt 26. Okt 2002, 08:53
zu Punkt 4. Deine momentane Internet IP liest du so aus:

Code:
function GetLocalIPs: String;
type PPInAddr= ^PInAddr;
var wsaData : TWSAData;
HostInfo : PHostEnt;
HostName : Array[0..255] of Char;
Addr    : PPInAddr;

begin
if WSAStartup($0102, wsaData) <> 0 then Exit;
try if GetHostName(HostName, SizeOf(HostName)) <> 0 then
begin
result:='';
Exit;
end;
HostInfo:= GetHostByName(HostName);
if HostInfo=nil then
begin
result:='';
Exit;
end;
Addr:=Pointer(HostInfo^.h_addr_list);
if (Addr=nil) or (Addr^=nil) then
begin
result:='';
Exit;
end;
if not (copy(strpas(inet_ntoa(addr^^)),1,7) = '192.168') then
begin
  result:=StrPas(inet_ntoa(Addr^^));
  inc(Addr);
end
 else
   begin
   inc(addr);
   while Addr^ <> nil do
     begin
       result:=StrPas(inet_ntoa(Addr^^));
      inc(Addr);
     end;
   end;
finally WSACleanup;
end;
end;
Mfg Salomon
01001000 01100001 01101100 01101100 01101111
01010111 01100101 01101100 01110100 00100001

http://www.it-adviser.net
  Mit Zitat antworten Zitat