Autor Beitrag
Boromir
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 45



BeitragVerfasst: Do 30.01.03 16:22 
Hi,

wie kann ich die IP eines Rechners im Netzwerk durch den Rechnername herausfinden? Wie funktioniert das mit den pingen??

Habt ihr einen Code?

THX
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 30.01.03 18:01 
Du müsstest die IP über das DNS system auflösen !!!

Dazu gibts ne kompo bei den INDYs !!! und auch gleich ein demo dazu !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
O'rallY
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 563



BeitragVerfasst: Do 30.01.03 21:27 
Du solltest wegen dem Pingen mit Indy mal im Forum suchen, da findest du mit Sicherheit was.

Hier mal beide Richtungen der Namensauflösung: 1. von der IP zum Namen und 2. umgekehrt:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
uses 
  WinSock; 

function IPAddrToName(IPAddr: string): string; 
var 
  SockAddrIn: TSockAddrIn; 
  HostEnt: PHostEnt; 
  WSAData: TWSAData; 
begin 
  WSAStartup($101, WSAData); 
  SockAddrIn.sin_addr.s_addr := inet_addr(PChar(IPAddr)); 
  HostEnt := gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET); 
  if HostEnt <> nil then 
    Result := StrPas(Hostent^.h_name) 
  else 
    Result := ''; 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
  ShowMessage(IPAddrToName('127.0.0.1')); 
end; 

{**************************************} 

// Function to get the IP Address from a Host 

function GetIPFromHost(const HostName: string): string; 
type 
  TaPInAddr = array[0..10] of PInAddr; 
  PaPInAddr = ^TaPInAddr; 
var 
  phe: PHostEnt; 
  pptr: PaPInAddr; 
  i: Integer; 
  GInitData: TWSAData; 
begin 
  WSAStartup($101, GInitData); 
  Result := ''; 
  phe := GetHostByName(PChar(HostName)); 
  if phe = nil then Exit; 
  pPtr := PaPInAddr(phe^.h_addr_list); 
  i := 0; 
  while pPtr^[i] <> nil do 
  begin 
    Result := inet_ntoa(pptr^[i]^); 
    Inc(i); 
  end; 
  WSACleanup; 
end;

_________________
.oO'rallY
Linux is like a tipi: No gates, no windows and a gnu-eating apache inside...