Option ExplicitPrivate Type QOCINFO dwSize As Long dwFlags As Long dwInSpeed As Long dwOutSpeed As Long End TypePrivate Const NETWORK_ALIVE_LAN As Long = &H1 ' LAN Private Const NETWORK_ALIVE_WAN As Long = &H2 ' RAS Private Const NETWORK_ALIVE_AOL As Long = &H4 ' AOL (Win95/98)
Private Declare Function IsDestinationReachable Lib "sensapi.dll" _ Alias "IsDestinationReachableA" _ (ByVal lpszDestination As String, _ lpQOCInfo As QOCINFO) As LongPublic Function IsNetConnectionAlive(ByVal strIP As String) As Boolean
Dim result As Long Dim qoc As QOCINFO qoc.dwSize = Len(qoc)
shell "ping 192.168.11.1 > c:\plog.txt"
然后分析plog.txt中的内容即可用API的网上搜索一下,示例代码有许多
dwSize As Long
dwFlags As Long
dwInSpeed As Long
dwOutSpeed As Long
End TypePrivate Const NETWORK_ALIVE_LAN As Long = &H1 ' LAN
Private Const NETWORK_ALIVE_WAN As Long = &H2 ' RAS
Private Const NETWORK_ALIVE_AOL As Long = &H4 ' AOL (Win95/98)
Private Declare Function IsDestinationReachable Lib "sensapi.dll" _
Alias "IsDestinationReachableA" _
(ByVal lpszDestination As String, _
lpQOCInfo As QOCINFO) As LongPublic Function IsNetConnectionAlive(ByVal strIP As String) As Boolean
Dim result As Long
Dim qoc As QOCINFO qoc.dwSize = Len(qoc)
result = IsDestinationReachable(strIP, qoc) '测试IP
IsNetConnectionAlive = qoc.dwFlags
End Function
shell "net use Z: '服务器电脑IP\IPC$' '密码' 、USER: 'username' "
...............