会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛
当前位置:主页 > 技巧 > Access技巧 > API > 正文

Access VBA 判断网络是否连通的多种办法(函数源码)(3)

时间:2013-11-08 17:40 来源:ffice中国 作者:网络 阅读:
  Exit Function 
 End If 
 Tstatus.dwSize = 160 
 RetVal = RasGetConnectStatus(TRasCon(0) 
.hRasCon,Tstatus) 
 If Tstatus.RasConnState = &H2000 Then 
  IsConnected = TRUE 
 Else 
  IsConnected = FALSE 
 End If 
End Function 
----------------------------------------------------
这个函数判断挺好,但在网络不通时连接比较慢
API 函数声明
Public Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwflags As Long, ByVal dwReserved As Long) As Long
 
Private Sub Form_Load()
 If InternetCheckConnection("http://www.baidu.com/", 1, 0) = 0 Then
     MsgBox "网络不正常"
    Else
        MsgBox "网络正常"
    End If
End Sub
 
 
---------------------------------------
这个函数比较快,但有时判断不准确
 
Private Type WSADATA
    wversion As Integer
    wHighVersion As Integer
    szDescription(0 To 256) As Byte
    szSystemStatus(0 To 128) As Byte
    iMaxSockets As Integer
    iMaxUdpDg As Integer
    lpszVendorInfo As Long
End Type
 

(责任编辑:admin)

顶一下
(2)
100%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: