S
sprite
Unregistered / Unconfirmed
GUEST, unregistred user!
用 WINSOCK API 写了个N简单的程序 就是用不能用
如下
procedure TForm1.Button1Click(Sender: TObject);
const
WINSOCK_VERSION=$0200;
AF_INET_LENGTH=4;
var
wsaDATA:TWSADATA;
lpHostEntHOSTENT;
dwIpAddrWORD;
szIpAddrCHAR;
begin
//new(lpHostEnt);
if (WSAStartup(WINSOCK_VERSION,wsaDATA)=0) then
ShowMessage('Start Error')
else
begin
lpHostEnt:=gethostbyname('www.263.net');
if lpHostEnt=nil then ShowMessage('Get Error')
else
begin
szIpAddr:=inet_ntoa(Tinaddr(lpHostEnt^.h_addr_list));
MessageBox(0,szIpAddr,'hehe',MB_OK);
end;
end;
//freemem(szIpAddr);
{ dwIpAddr:=inet_addr('210.34.0.13');
ShowMessage(inttostr(dwIpAddr));
lpHostEnt:=gethostbyaddr(@dwIpAddr,AF_INET_LENGTH,AF_INET);
if lpHostEnt<>nil then ShowMessage(lpHostEnt^.h_name);
}
//dispose(lpHostEnt);
WSACleanup;
end;
就是老是 Get Error
望高手指教
如下
procedure TForm1.Button1Click(Sender: TObject);
const
WINSOCK_VERSION=$0200;
AF_INET_LENGTH=4;
var
wsaDATA:TWSADATA;
lpHostEntHOSTENT;
dwIpAddrWORD;
szIpAddrCHAR;
begin
//new(lpHostEnt);
if (WSAStartup(WINSOCK_VERSION,wsaDATA)=0) then
ShowMessage('Start Error')
else
begin
lpHostEnt:=gethostbyname('www.263.net');
if lpHostEnt=nil then ShowMessage('Get Error')
else
begin
szIpAddr:=inet_ntoa(Tinaddr(lpHostEnt^.h_addr_list));
MessageBox(0,szIpAddr,'hehe',MB_OK);
end;
end;
//freemem(szIpAddr);
{ dwIpAddr:=inet_addr('210.34.0.13');
ShowMessage(inttostr(dwIpAddr));
lpHostEnt:=gethostbyaddr(@dwIpAddr,AF_INET_LENGTH,AF_INET);
if lpHostEnt<>nil then ShowMessage(lpHostEnt^.h_name);
}
//dispose(lpHostEnt);
WSACleanup;
end;
就是老是 Get Error
望高手指教