clientsocket.address := 'xxx.xxx.xxx.xxx'自己做好了.
子网掩码:是不是一样?
子网掩码:是不是一样?
解决方案 »
- Delphi 怎样 把TParams 或 record写到流里面
- for 循环数值过大,会引起异常。
- delphi2006编译
- 保存为Excel文件的问题?
- 怎么设置输入法
- adotable对象打开数据表时,如何按 sortfield 字段排序?
- 难道无人知道:这个MTS/COM+三层问题(第三贴请教)?????????
- delphi中怎样在combobox中增加item时,同时给他赋另外一个值?就像vb中的itemdata一样!!1急,在线等!!!
- 高手:webbrowser1.offline:=false ,为什么它还能打开不存在的页面?
- 老千,上次的那个rose下载网站,你还记得吗?偶忘了,搜索了几遍野没找到//牛虻
- 如何在ListView中出现上下排序箭头?
- 哪位朋友有“DELPHI控件大全”之类的电子书?
一样的话,可以用winapi 网络资源搜索,函数来搜索啊!
具体可参考某位高人写的程序:constructor TIPThred.Create(IP: String);
begin
FIP := IP;
inherited Create(true);
FreeOnTerminate:=true;
Resume;
end;procedure TIPThred.Execute;
const
Size = 56;
TimeOut = 1000;
var
Address: DWord; // Address of host to contact
HostName, HostIP: String; // Name and dotted IP of host to contact
Phe: PHostEnt; // HostEntry buffer for name lookup
BufferSize, nPkts: Integer;
pReqData, pData: Pointer;
pIPE: PIcmpEchoReply; // ICMP Echo reply buffer
IPOpt: TIPOptionInformation; // IP Options for packet to send i: integer;
begin
// Do a lookup Address := inet_addr(PChar(FIP)); if (Address = INADDR_NONE) then begin
Phe := GetHostByName(PChar(FIP));
if Phe = Nil then
begin
;
//ShowError(WSAGetLastError)
end
else begin
Address := longint(plongint(Phe^.h_addr_list^)^);
HostName := Phe^.h_name;
HostIP := StrPas(inet_ntoa(TInAddr(Address)));
end;
end
else begin
Phe := GetHostByAddr(@Address, 4, PF_INET);
if Phe = Nil then
begin
;
//ShowError(WSAGetLastError)
end
else begin
HostName := Phe^.h_name;
HostIP := StrPas(inet_ntoa(TInAddr(Address)));
end;
end; if Address = INADDR_NONE then
begin
;//Memo1.Lines.Add('Cannot resolve hostname ' + Edit1.Text);
end
else
begin
//Memo1.Lines.Add('Sending ' + IntToStr(Size) + ' bytes to ' +
//HostName + ' (' + HostIP + ')'); // Get some data buffer space and put something in the packet to send
BufferSize := SizeOf(TICMPEchoReply) + Size;
GetMem(pReqData, Size);
GetMem(pData, Size);
GetMem(pIPE, BufferSize);
FillChar(pReqData^, Size, $AA);
pIPE^.Data := pData; // Finally Send the packet
FillChar(IPOpt, SizeOf(IPOpt), 0);
IPOpt.TTL := 64;
NPkts := IcmpSendEcho(hICMP, Address, pReqData, Size,
@IPOpt, pIPE, BufferSize, TimeOut);
if NPkts = 0 then
begin
//ShowError(GetLastError)
end
else begin
//ShowMessage('ok');
HostIP := StrPas(inet_ntoa(TInAddr(pIPE^.Address)));
IPMsg := HostIP;
for i := length(HostIP) to 16 do
begin
IPMsg := IPMsg + ' ';
end;
IPMsg := IPMsg + HostName;
Synchronize(DispIPMsg);
//Memo1.Lines.Add('Received ' + IntToStr(pIPE^.DataSize) +
//' bytes from ' + HostIP +
//' in ' + IntToStr(pIPE^.RTT) + ' msecs')
end; // Free those buffers
FreeMem(pIPE);
FreeMem(pData);
FreeMem(pReqData);
end;
end;