请问如何检测与internet的拨号连接,并且中止它?(200分)

L

lufang

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何检测与internet的拨号连接,并且中止它?
 
弄个拨号程序
 
检测的连网:
Function Inetisoffline(flag:integer):boolean;stdcall;extenal 'url.dll';

if Inetisoffline(0) then
没有连网
else
连接上网
 
简单的可以PING 一下某个网站。
 
procedure TForm1.Button1Click(Sender: TObject);
begin
if GetSystemMetrics(SM_NETWORK) AND $01 = $01 then
ShowMessage('Machine is attached to network') else
ShowMessage('Machine is not attached to network');
end;
 
还有吗?要散分了
 
关于naughtboy的回答:
procedure TForm1.Button1Click(Sender: TObject);
begin
if GetSystemMetrics(SM_NETWORK) AND $01 = $01 then
ShowMessage('Machine is attached to network') else
ShowMessage('Machine is not attached to network');
end;

-------------------------
这个不对 无论上网还是没有上网,都显示'Machine is attached to network'
 
procedure TForm1.Button1Click(Sender: TObject);
begin
if InternetCheckConnection('http://www.163.com/', 1, 0) then
edit1.text:= 'Connected'
else
edit1.text:= 'Disconnected';
end;
 
function TForm1.CheckOffline: boolean;
var
ConnectState: DWORD;
StateSize: DWORD;
begin
ConnectState:= 0;
StateSize:= SizeOf(ConnectState);
result:= false;
if InternetQueryOption(nil, INTERNET_OPTION_CONNECTED_STATE, @ConnectState, StateSize) then
if (ConnectState and INTERNET_STATE_DISCONNECTED) <> 2 then result:= true;
end;
 
第一个是检测网络是否通的。
第二个是检测是否可以连网的。
这个是检测拨号类型的
procedure TForm1.Button3Click(Sender: TObject);
var m:TConnectionType;
begin
m:=ConnectedToInternet;
case m of
ctNone :edit3.text:='ctnone';
ctProxy :edit3.Text:='ctproxy';
ctDialup :edit3.text:='ctdialup';
end;
end;
 
Undeclared identifier'TConnectionType'
 
顶部