这段代码为何不能ping通由sygate代理出去的ip????????????????????????(100分)

  • 主题发起人 主题发起人 gouer
  • 开始时间 开始时间
G

gouer

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, winsock,SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, jpeg;

type
PIPOptionInformation = ^TIPOptionInformation;
TIPOptionInformation = packed record
TTL: Byte;
TOS: Byte;
Flags: Byte;
OptionsSize: Byte;
OptionsData: PChar;
end;
PIcmpEchoReply = ^TIcmpEchoReply;
TIcmpEchoReply = packed record
Address: DWORD;
Status: DWORD;
RTT: DWORD;
DataSize: Word;
Reserved: Word;
Data: Pointer;
Options: TIPOptionInformation;
end;
TIcmpCreateFile = function: THandle; stdcall;
TIcmpCloseHandle = function(IcmpHandle: THandle): Boolean; stdcall;
TIcmpSendEcho = function(IcmpHandle:THandle;
DestinationAddress: DWORD;
RequestData: Pointer;
RequestSize: Word;
RequestOptions: PIPOptionInformation;
ReplyBuffer: Pointer;
ReplySize: DWord;
Timeout: DWord
): DWord; stdcall;
Tmyping = class(TForm)
Panel1: TPanel;
pingedit: TEdit;
exebutton: TButton;
StatusShow: TMemo;
Label1: TLabel;
Image1: TImage;
Image2: TImage;
procedure FormCreate(Sender: TObject);
procedure exebuttonClick(Sender: TObject);
private
{ Private declarations }
hICMP: THANDLE;
IcmpCreateFile : TIcmpCreateFile;
IcmpCloseHandle: TIcmpCloseHandle;
IcmpSendEcho: TIcmpSendEcho;
public
{ Public declarations }
end;

var
myping: Tmyping;

implementation

{$R *.DFM}

procedure Tmyping.FormCreate(Sender: TObject);
var
WSAData: TWSAData;
hICMPdll: HMODULE;
begin
wsastartup($101,wsadata);
hICMPdll := LoadLibrary('icmp.dll');
@ICMPCreateFile := GetProcAddress(hICMPdll, 'IcmpCreateFile');
@IcmpCloseHandle := GetProcAddress(hICMPdll, 'IcmpCloseHandle');
@IcmpSendEcho := GetProcAddress(hICMPdll, 'IcmpSendEcho');
hICMP := IcmpCreateFile;
StatusShow.Text := '';
//StatusShow.Lines.Add('目的IP地址 字节数 返回时间(毫秒)');
end;

procedure Tmyping.exebuttonClick(Sender: TObject);
var
IPOpt:TIPOptionInformation;// IP Options for packet to send
FIPAddress:DWORD;
pReqData,pRevData:PChar;
pIPE:PIcmpEchoReply;// ICMP Echo reply buffer
FSize: DWORD;
MyString:string;
FTimeOut:DWORD;
BufferSize:DWORD;
begin
if PingEdit.Text <> '' then
begin
FIPAddress := inet_addr(PChar(PingEdit.Text));
FSize := 40;
BufferSize := SizeOf(TICMPEchoReply) + FSize;
GetMem(pRevData,FSize);
GetMem(pIPE,BufferSize);
FillChar(pIPE^, SizeOf(pIPE^), 0);
pIPE^.Data := pRevData;
MyString := 'Hello,World';
pReqData := PChar(MyString);
FillChar(IPOpt, Sizeof(IPOpt), 0);
IPOpt.TTL := 64;
FTimeOut := 4000;
IcmpSendEcho(hICMP, FIPAddress, pReqData, Length(MyString), @IPOpt, pIPE, BufferSize, FTimeOut);
try
if pReqData^ = pIPE^.Options.OptionsData^ then
begin
StatusShow.Lines.Add(PChar(PingEdit.Text) + ' ' +IntToStr(pIPE^.DataSize) + ' ' +IntToStr(pIPE^.RTT));
end;
except
messagedlg('没有找到该IP地址!',mtinformation,[mbok],0);
end;
FreeMem(pRevData);
FreeMem(pIPE);
end;
end;

end.
我在我的机器上通过sygate上网,当我用他ping我们工作组的ip就可以,但是当我
ping internet上的ip为何不行,各位大虾,帮忙看看!!!!!!!
如何解决呢??????????????????????????????

 
代理服务器不提供IP搜索功能, 估计是这样!?
 
如果运行ping不能ping通,说明你的程序不一定有问题

如果运行ping能ping通,你的程序不同,说明你的程序一定有问题

 
直接!^-^
 
有代理是不能ping外面的,除非服务器上允许你不通过代理出去,那么
你可以加上网关,即把网关设为局域网和外界接口的那个交换机的地址,
再有DNS就可以了。
 
可是我可以用ping通阿!难道没有人回答了吗
 
好像是超时了吧
 
是不是也要在程序里指定网关呢?
 
gouer:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。
 
多人接受答案了。
 
后退
顶部