怎么用VB代码察看网络连接通不通``?

来源:百度知道 编辑:UC知道 时间:2024/07/02 14:56:20
比如说\\new13\come\CS1.6.EXE 在NEW13号上共享```
NEW13号限制为10个人连入用 SHELL "\\new13\come\CS1.6.EXE" 打开文件时,人数上限,或NEW13 没开机时会错误,就是连接不通拉..
有没什么代码能查网络通不通的..如果通则执行,不通则退出,这样就不会发生错误了``
可以说明白一点吗。。
比如说我要PING \\new13 (192.168.0.13) 要怎么做。。如果不通就FORM2.SHOW 通就FORM1.SHOW 具体该怎么弄``

这句能运行吗?
Call IIf(isIpConected("\\new13"), Form1.Show, FORM2.Show)

'通过ping测试,strIP是要测试的IP
Private Function isIpConected(strIP As String) As Boolean
    Shell "cmd /c del c:\testip & " & strIP & ">>c:\testip", 0
    Sleep 2000
    Dim strTempInput As String
    Open "c:\testip" For Input As #1
    Do While Not EOF(1)
        Line Input #1, strTempInput
        If InStr(strTempInput, "Reply") > 0 Then '含有Reply关键字就表示Ping的通