如何获得指定IP的计算机当前的网络流量? 如何获得指定IP的计算机当前的网络流量?给个思路也行!谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 找到这个,你参考一下。应该有用。怎么样检测两台电脑之间的网络连接是否正常用ping 了, 檢查icmp包的返回情況代碼:http://www.howtodothings.com/showarticle.asp?article=560unit Ping;interfaceuses Windows, SysUtils, Classes;type TSunB = packed record s_b1, s_b2, s_b3, s_b4: byte; end; TSunW = packed record s_w1, s_w2: word; end; PIPAddr = ^TIPAddr; TIPAddr = record case integer of 0: (S_un_b: TSunB); 1: (S_un_w: TSunW); 2: (S_addr: longword); end; IPAddr = TIPAddr;function IcmpCreateFile : THandle; stdcall; external 'icmp.dll';function IcmpCloseHandle (icmpHandle : THandle) : boolean; stdcall; external 'icmp.dll'function IcmpSendEcho (IcmpHandle : THandle; DestinationAddress : IPAddr; RequestData : Pointer; RequestSize : Smallint; RequestOptions : pointer; ReplyBuffer : Pointer; ReplySize : DWORD; Timeout : DWORD) : DWORD; stdcall; external 'icmp.dll';function Ping(InetAddress : string) : boolean;implementationuses WinSock;function Fetch(var AInput: string; const ADelim: string = ' '; const ADelete: Boolean = true) : string;var iPos: Integer;begin if ADelim = #0 then begin // AnsiPos does not work with #0 iPos := Pos(ADelim, AInput); end else begin iPos := Pos(ADelim, AInput); end; if iPos = 0 then begin Result := AInput; if ADelete then begin AInput := ''; end; end else begin result := Copy(AInput, 1, iPos - 1); if ADelete then begin Delete(AInput, 1, iPos + Length(ADelim) - 1); end; end;end;procedure TranslateStringToTInAddr(AIP: string; var AInAddr);var phe: PHostEnt; pac: PChar; GInitData: TWSAData;begin WSAStartup($101, GInitData); try phe := GetHostByName(PChar(AIP)); if Assigned(phe) then begin pac := phe^.h_addr_list^; if Assigned(pac) then begin with TIPAddr(AInAddr).S_un_b do begin s_b1 := Byte(pac[0]); s_b2 := Byte(pac[1]); s_b3 := Byte(pac[2]); s_b4 := Byte(pac[3]); end; end else begin raise Exception.Create('Error getting IP from HostName'); end; end else begin raise Exception.Create('Error getting HostName'); end; except FillChar(AInAddr, SizeOf(AInAddr), #0); end; WSACleanup;end;function Ping(InetAddress : string) : boolean;var Handle : THandle; InAddr : IPAddr; DW : DWORD; rep : array[1..128] of byte;begin result := false; Handle := IcmpCreateFile; if Handle = INVALID_HANDLE_VALUE then Exit; TranslateStringToTInAddr(InetAddress, InAddr); DW := IcmpSendEcho(Handle, InAddr, nil, 0, nil, @rep, 128, 0); Result := (DW <> 0); IcmpCloseHandle(Handle);end;end. 如何清除PaintBox 时间段过滤的问题!急! 帮帮忙 谢谢了各位! to zbird(谢谢,接分2) 怎样让封面不显示页码,从第二页开始计算页码 子,父窗体的显示问题??????????迷惑??????? 我有三个imagelist控件 我想把三个imagelist里的ico合并在一起??? 谁能告诉我获得一个文本文件的大小的方法?急! 请教,如何在WIN NT 中注册控件? 当ManiForm为StayOnTop时,怎么样显示其它窗口,如输入框,消息框,是否都要设成"总在前面"? 关于窗口重画的问题,求助 关于如何开发软件注册程序的一个问题。
用ping 了, 檢查icmp包的返回情況
代碼:
http://www.howtodothings.com/showarticle.asp?article=560
unit Ping;interface
uses
Windows, SysUtils, Classes;type
TSunB = packed record
s_b1, s_b2, s_b3, s_b4: byte;
end; TSunW = packed record
s_w1, s_w2: word;
end; PIPAddr = ^TIPAddr;
TIPAddr = record
case integer of
0: (S_un_b: TSunB);
1: (S_un_w: TSunW);
2: (S_addr: longword);
end; IPAddr = TIPAddr;function IcmpCreateFile : THandle; stdcall; external 'icmp.dll';
function IcmpCloseHandle (icmpHandle : THandle) : boolean; stdcall; external 'icmp.dll'
function IcmpSendEcho (IcmpHandle : THandle; DestinationAddress : IPAddr;
RequestData : Pointer; RequestSize : Smallint;
RequestOptions : pointer;
ReplyBuffer : Pointer;
ReplySize : DWORD;
Timeout : DWORD) : DWORD; stdcall; external 'icmp.dll';
function Ping(InetAddress : string) : boolean;implementationuses
WinSock;function Fetch(var AInput: string; const ADelim: string = ' '; const ADelete: Boolean = true)
: string;
var
iPos: Integer;
begin
if ADelim = #0 then begin
// AnsiPos does not work with #0
iPos := Pos(ADelim, AInput);
end else begin
iPos := Pos(ADelim, AInput);
end;
if iPos = 0 then begin
Result := AInput;
if ADelete then begin
AInput := '';
end;
end else begin
result := Copy(AInput, 1, iPos - 1);
if ADelete then begin
Delete(AInput, 1, iPos + Length(ADelim) - 1);
end;
end;
end;procedure TranslateStringToTInAddr(AIP: string; var AInAddr);
var
phe: PHostEnt;
pac: PChar;
GInitData: TWSAData;
begin
WSAStartup($101, GInitData);
try
phe := GetHostByName(PChar(AIP));
if Assigned(phe) then
begin
pac := phe^.h_addr_list^;
if Assigned(pac) then
begin
with TIPAddr(AInAddr).S_un_b do begin
s_b1 := Byte(pac[0]);
s_b2 := Byte(pac[1]);
s_b3 := Byte(pac[2]);
s_b4 := Byte(pac[3]);
end;
end
else
begin
raise Exception.Create('Error getting IP from HostName');
end;
end
else
begin
raise Exception.Create('Error getting HostName');
end;
except
FillChar(AInAddr, SizeOf(AInAddr), #0);
end;
WSACleanup;
end;function Ping(InetAddress : string) : boolean;
var
Handle : THandle;
InAddr : IPAddr;
DW : DWORD;
rep : array[1..128] of byte;
begin
result := false;
Handle := IcmpCreateFile;
if Handle = INVALID_HANDLE_VALUE then
Exit;
TranslateStringToTInAddr(InetAddress, InAddr);
DW := IcmpSendEcho(Handle, InAddr, nil, 0, nil, @rep, 128, 0);
Result := (DW <> 0);
IcmpCloseHandle(Handle);
end;end.