Public Class Form1
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function GetaSyncKeystate(ByVal vkey As System.Windows.Forms.Keys) As Short
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Shell("cmd.exe /c ipconfig/renew")
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Shell("cmd.exe /c ipconfig/release")
End Sub
Private Sub Label1_Click(sender As System.Object, e As System.EventArgs) Handles Label1.Click
If My.Computer.Network.IsAvailable = True Then
Label1.Text = "Connected"
Label1.ForeColor = Color.Lime
If My.Computer.Network.IsAvailable = False Then
Label1.Text = "Disconnected"
Label1.ForeColor = Color.Red
End If
End If
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim hotkey As Boolean
hotkey = GetaSyncKeystate(Keys.L)
If hotkey = True Then
Button1.PerformClick()
End If
End Sub
End Class
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function GetAsyncKeyState(ByVal vk As Int32) As Int16
End Function
If My.Computer.Network.IsAvailable = True Then
Label1.Text = "Connected"
Label1.ForeColor = Color.Lime
ElseIf My.Computer.Network.IsAvailable = False Then
Label1.Text = "Disconnected"
Label1.ForeColor = Color.Red
End If