Вниз
Скачать: CL | DM;

Как зная IP адрес компа в сети получить его имя?   Найти похожие ветки 

← →
ctapik-net ©   (2002-01-18 13:26) [3]

Ну для меня это не так все просто, темболее ни разу этой функцией не пользовался.
Вот:
struct hostent FAR * gethostbyaddr (

const char FAR * addr,
int len,
int type
);


Parameters

addr

[in] A pointer to an address in network byte order.

len

[in] The length of the address.

type

[in] The type of the address.

Деляю так

Function GetHostNameByIP(IP : String) : String ;
Var
WSData : WSAData ;
wVersionRequested : Word ;
Len : Integer ;
P : PChar ;
HostEnt : PHostEnt ;
Begin
Result := "" ;
Try
If WSAStartup(wVersionRequested,WSData) = 0 Then Begin
Len := 260 ;
GetMem(P,Len) ;
StrPCopy(P,IP) ;
HostEnt := GetHostByAddr(P,Len,AF_INET) ;
If HostEnt<>Nil Then Begin
Result := HostEnt.h_name ;
End ;
FreeMem(P,Len) ;
End ;
Finally
WSACleanup ;
End ;
End ;

Но ничего не выходит!!!
Кстати если HostEnt <> Nil нужно освобождать из под него память или нет?



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.44 MB
Время: 0.014 c
1-69907
inko
2002-04-09 15:37
2002.04.22
Как реализовать проверку расширения файлов?


1-69919
Oleon
2002-04-09 17:34
2002.04.22
Добрый вечер.


3-69711
Zombie
2002-04-01 08:18
2002.04.22
Containg в BDE


14-69985
Fellomena
2002-03-14 13:04
2002.04.22
VFortran & MultiThreads Applications


14-69998
Alx2
2002-03-15 07:57
2002.04.22
Merlin, с Днем Рождения!




   Наверх