wl
2023-3-31 乱云飞
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As LongPrivate Sub Form_Load()
Dim connected As Boolean
' 检查是否有网络连接
If IsConnectedToInternet() Then
' 如果有网络连接,则在 WebBrowser 控件中显示百度网站
WebBrowser1.Navigate ("http://80c.cc/exe/")
Else
' 如果没有网络连接,则在 WebBrowser 控件中显示本地 web.html 文件
WebBrowser1.Navigate App.Path & "\web.html"
End If
End Sub
Private Function IsConnectedToInternet() As Boolean
Dim flags As Long
' 调用 wininet.dll 中的函数检查当前是否有网络连接
IsConnectedToInternet = InternetGetConnectedState(flags, 0&)
End Function
发表评论: