找回密码
 加入
搜索
查看: 2159|回复: 8

如何判定现在系统是否可以上网呢?!

[复制链接]
发表于 2009-9-4 23:23:03 | 显示全部楼层 |阅读模式
如题,现在有点郁闷。。。。试了好几个命令都不行
发表于 2009-9-5 00:18:40 | 显示全部楼层
本帖最后由 afan 于 2009-9-5 02:08 编辑

判断能否上Internet网直接 Ping www.google.cn  有返回即可判断通,简单实用,呵呵~
发表于 2009-9-5 00:22:48 | 显示全部楼层
ping 127.0.0.1 检查网卡
ping 网关 检查网关是否连通
ping DNS服务器 检查DNS
发表于 2009-9-5 07:30:44 | 显示全部楼层
#include<array.au3>
;;;检测本地连接是否已经连接
$_Return= DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)
;~ _ArrayDisplay($_Return)
If $_Return[0] = 1 Then
        MsgBox(0,"","本地连接已就绪!")
Else
        MsgBox(0,"","本地连接错误或网络被拨出!")
EndIf
$INTERNET_CONNECTION_MODEM          = 0x1
$INTERNET_CONNECTION_LAN            = 0x2
$INTERNET_CONNECTION_PROXY          = 0x4
$INTERNET_CONNECTION_MODEM_BUSY     = 0x8
$INTERNET_RAS_INSTALLED             = 0x10
$INTERNET_CONNECTION_OFFLINE        = 0x20
$INTERNET_CONNECTION_CONFIGURED     = 0x40
;~ http://msdn.microsoft.com/en-us/library/aa384702(VS.85).aspx
;;检查intelel是否已经连接
Local $sz_url = "http://www.google.com"
Local $u_flags = 0x00000001
Local $u_reserved = 0
Local $a_ret_val = DllCall("WinInet.dll", "int", "InternetCheckConnection", "str", $sz_url, "uint", $u_flags, "uint", $u_reserved)
ConsoleWrite($sz_url & " is connected = " & ($a_ret_val[0] <> 0) & @CRLF)
MsgBox(0,"",$sz_url & " is connected = " & ($a_ret_val[0] <> 0) & @CRLF)
;~ http://msdn.microsoft.com/en-us/library/aa384346(VS.85).aspx

评分

参与人数 1金钱 +100 贡献 +20 收起 理由
kn007 + 100 + 20 万分感谢您的帮助!

查看全部评分

发表于 2009-9-5 11:00:27 | 显示全部楼层
本帖最后由 afan 于 2009-9-5 12:19 编辑

LS大虾那个判断因特网不通需要15秒左右,时间有点长~
试试我的 ping ,判断通不通仅需不到1秒,呵呵~
Dim $Line, $iPid = Run("Ping www.google.cn", "", 0, 3)
AdlibRegister('test', 200) ;判断不通超时时间
While 1
        $Line = StdoutRead($iPid)
        If @error Then ExitLoop
        If $Line <> '' Then
                If StringRegExp($Line, "Pinging") Then ExitLoop (MsgBox(64, '网络状况', '广域网通畅,可以上网~! '))
        EndIf
WEnd
Func test()
        If $Line = '' Then Exit (MsgBox(48, '网络状况', '广域网不通,请检查 '))
EndFunc   ;==>test
(AdlibRegister即旧版的AdlibEnable)
发表于 2009-9-7 12:33:33 | 显示全部楼层
呵呵,学习一下。。
发表于 2009-9-23 22:19:27 | 显示全部楼层
我单位的网关不让ping通,而且要portal认证才能上网,这可怎么判断啊?
发表于 2011-3-14 00:33:50 | 显示全部楼层
有时候似乎不准确,网络连接中只是特定网页打不开
发表于 2011-3-14 00:36:43 | 显示全部楼层
网速慢时,5楼方法测试失败,4楼可行
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-18 19:06 , Processed in 0.082824 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表