但是有个问题,我的机器在局域网里,用下面这代码procedure TForm1.Button1Click(Sender: TObject); begin if InetIsOffline(0) then Edit1.Text:='Offline' else Edit1.Text:='Online' end;不管在不在线,都显示ONLINE
: yypp(彭哥) 你看我的定义对不对? 怎么每次运行都出错? 他说没法找到接入点?function InetIsOffLine(dwFlags:dword):WordBool;safecall; var Form1: TForm1;implementation function InetIsOffLine(dwFlags:dword):WordBool;external 'url.dll';
faint!!! 我拔掉网线,还是online???crazy! 跟我上一次用InternetGetConnectedState一模一样!!! 但我发现: procedure TForm1.Button1Click(Sender: TObject); begin IdIpWatch1.Active:=True; if IdIpWatch1.ForceCheck=True then begin ShowMessage('Ok'); end; end; //indy的控件却是有用,可判断网络连通状态!delphi6由这些控件! 但原理,我看了源程序后,还没搞清楚!看懂了,跟我讲一声
经过摸索,觉得下面这个方法是最有效的 user WinInet procedure TForm1.Button1Click(Sender: TObject); begin if InternetCheckConnection('http://www.yahoo.com/', 1, 0) then edit1.text:= 'Connected' else edit1.text:= 'Disconnected';end; 就是执行时候的速度不太令人满意
begin
if InetIsOffline(0) then
Edit1.Text:='Offline'
else
Edit1.Text:='Online'
end;不管在不在线,都显示ONLINE
怎么每次运行都出错?
他说没法找到接入点?function InetIsOffLine(dwFlags:dword):WordBool;safecall;
var
Form1: TForm1;implementation
function InetIsOffLine(dwFlags:dword):WordBool;external 'url.dll';
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationfunction InetIsOffline (dwFlags
:DWORD):BOOL; stdcall; external 'url.DLL';{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
if InetIsOffline(0) then
Edit1.Text:='Offline'
else
Edit1.Text:='Online'
end;end.
我拔掉网线,还是online???crazy!
跟我上一次用InternetGetConnectedState一模一样!!!
但我发现:
procedure TForm1.Button1Click(Sender: TObject);
begin
IdIpWatch1.Active:=True;
if IdIpWatch1.ForceCheck=True then
begin
ShowMessage('Ok');
end;
end;
//indy的控件却是有用,可判断网络连通状态!delphi6由这些控件!
但原理,我看了源程序后,还没搞清楚!看懂了,跟我讲一声
user WinInet
procedure TForm1.Button1Click(Sender: TObject);
begin if InternetCheckConnection('http://www.yahoo.com/', 1, 0) then
edit1.text:= 'Connected'
else
edit1.text:= 'Disconnected';end;
就是执行时候的速度不太令人满意
我还用icmp.dll