![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Как узнать в Вин IP адрес? [D6, Win95/98, WinME, NT4, Win2k, WinXP]
трям © (2003-03-26 01:12:00)желательно на API:)
Smithson (2003-03-26 15:25:00) [1]
function GetIPaddress: String;
const bufsize = 255;
var WSA: WSAData;
buf: pointer;
RemoteHost : PHostEnt; (* No, don"t free it! *)
D: record
case Byte of
0: ( L: LongInt );
1: ( B: Array[0..3] of byte );
end;
Begin
WSAStartUp($101,WSA);
buf:=NIL;
try
getmem(buf,bufsize);
winsock.gethostname(buf,bufsize); (* this one maybe without domain *)
RemoteHost:=Winsock.GetHostByName(buf);
if RemoteHost=NIL then
Result := "No TCP/IP" (* 127.0.0.1 *)
else begin
D.L := longint(pointer(RemoteHost^.h_addr_list^)^);
Result := IntToStr(D.B[0])+"."+IntToStr(D.B[1])+"."+IntToStr(D.B[2])+"."+IntToStr(D.B[3]);
end;
finally
if buf <> NIL then freemem(buf,bufsize);
end;
WSACleanup();
End;
Landgraph (2003-03-26 14:18:00) [2]про udp забыли =)
Alex Konshin (2003-03-26 01:40:00) [3]и без tcp/ip!:)
трям (2003-03-26 01:19:00) [4]и без winsocka !:)