Thread View: cn.bbs.comp.winsock
1 messages
1 total messages
Started by iceberg
Thu, 06 Aug 1998 00:00
Re: ����ڳ����л�ȡ�����IP
Author: iceberg
Date: Thu, 06 Aug 1998 00:00
Date: Thu, 06 Aug 1998 00:00
103 lines
4947 bytes
4947 bytes
�� �� dsp (Juliet) �Ĵ������ᵽ: ��
: �� �� dsp (Juliet) �Ĵ������ᵽ: ��
: : �ٻ�һ��Delphi3�ɣ��������У���
: : ����ÿؼ��ĵ�ԪΪwinsock��isp3.��֪Active x �ؼ�������Ƿ�����ͨ
: : �ؼ�һ��ԪActivexҲ�������á�Good luck!
: : ��������ؼ��㶼�У������Ϊ�������⣬REINSTALL it!!!
: ~~~~~��Ԫ(sorry for the error spell)
: ���⣺Remember: Tcp�ؼ���[internet] ҳ�ϣ����[active x]ҳ��
new:
�����ҵ�һ������Winsock API��ñ���IP�ķ�����
Ҫ������'0.0.0.0'��IP��ַ���γ�IP byte code��
Ȼ�����gethostbyaddr����õ���������֣���
�ô����ֵ���gethostbyname�����ɵõ������IP.
��������delphiʵ�ֵ��㷨��Ϊ���ڳ���ʱȷ��
��λ�����������ӵij��?����롣
procedure TForm1.Button1Click(Sender: TObject);
var
p : array[0..200] of char;
s1 : PHOSTENT;
str : string;
pdata : TWSADATA;
inaddr : TInAddr;
k:integer;
addr:longint;
pa:Pointer;
begin
k:=WSAStartup($0101,pdata);
str:='';
if (k = 0) then
begin
strPcopy(p,'0.0.0.0');
addr:=inet_addr(p);
pa:=@addr;
s1:=gethostbyAddr(pa,4,PF_INET);
if s1<>nil then
begin
s1:=gethostbyname(s1.h_name);
if s1<>nil then
begin
inaddr.S_un_b.s_b1 := s1.h_addr_list^[0];
inaddr.S_un_b.s_b2 := s1.h_addr_list^[1];
inaddr.S_un_b.s_b3 := s1.h_addr_list^[2];
inaddr.S_un_b.s_b4 := s1.h_addr_list^[3];
str := strpas(inet_ntoa(inaddr));
end
else
case WSAGetLastError of
WSANOTINITIALISED:str:='A successful WSAStartup must occur before'+
' using this function.';
WSAENETDOWN: str:='The Windows Sockets implementation has detected'+
'that the network subsystem has failed.';
WSAHOST_NOT_FOUND: str:='Authoritative Answer Host not found.';
WSATRY_AGAIN: str:='Non-Authoritative Host not found, or ' +
'SERVERFAIL.';
WSANO_RECOVERY: str:='Nonrecoverable errors: FORMERR, REFUSED,' +
' NOTIMP.';
WSANO_DATA:str:='Valid name, no data record of requested type.';
WSAEINPROGRESS:str:='A blocking Windows Sockets operation is in '+
'progress.';
WSAEINTR:str:='The (blocking) call was canceled using' +
'WSACancelBlockingCall.';
end
end
else
case WSAGetLastError of
WSANOTINITIALISED:str:='A successful WSAStartup must occur before' +
' using this function.';
WSAENETDOWN:str:='The Windows Sockets implementation has detected' +
' that the network subsystem has failed.';
WSAHOST_NOT_FOUND:str:='Authoritative Answer Host not found.';
WSATRY_AGAIN:str:='Non-Authoritative Host not found, or SERVERFAIL.';
WSANO_RECOVERY:str:='Nonrecoverable errors: FORMERR, REFUSED,'
+ ' NOTIMP.';
WSANO_DATA:str:='Valid name, no data record of requested type.';
WSAEINPROGRESS:str:='A blocking Windows Sockets operation is ' +
'in progress.';
WSAEINTR:str:='The (blocking) call was canceled using ' +
'WSACancelBlockingCall.';
end;
end
else
begin
case k of
WSASYSNOTREADY:str:='Indicates that the underlying network ' +
'subsystem is not ready for network communication.';
WSAVERNOTSUPPORTED: str:='The version of Windows Sockets ' +
'support requested is not provided' +
'by this particular Windows Sockets implementation.';
WSAEINVAL:str:='The Windows Sockets version specified by the ' +
'application is not supported by this DLL.';
end;
end;
Label1.Caption:=str;
WSACleanup;
end;
--
ң֪����ѩ��Ω�а�����...
[m[1;35m�� ��Դ:���̺����� bbs.dlut.edu.cn��[FROM: 202.118.68.10][m
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads