16,718
社区成员
发帖
与我相关
我的任务
分享
Namespace My
Class MyApplication
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
Call SetConnectionStatus(My.Computer.Network.IsAvailable)
End Sub
Private Sub MyApplication_NetworkAvailabilityChanged(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.Devices.NetworkAvailableEventArgs) Handles Me.NetworkAvailabilityChanged
Call SetConnectionStatus(My.Computer.Network.IsAvailable)
End Sub
Private Sub SetConnectionStatus(ByVal Connected As Boolean)
With My.Forms.Form2.ConnectedStatusLabel
If Connected Then
.Image = My.Resources.connected.ToBitmap
.Text = My.Resources.ConnectedText
Else
.Image = My.Resources.disconnected.ToBitmap
.Text = My.Resources.DisconnectedText
End If
End With
End Sub
End Class
End Namespace
[DllImport("Wininet.dll")]
private static extern bool InternetGetConnectedState(out int lpdwFlags, int dwReserved);