[CODE] Private Sub ConnectionLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectionLabel.Click
My.Forms.Network_Info.Show()
Dim voice As New SpVoice
voice.Speak("Network Information")
End Sub
******************************************************
Option Explicit
Imports System.IO
Imports System
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Management
Imports System.Security
Imports SpeechLib
Public Class Network_Info
#Region " Functions "
#Region " API "
Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000
Private Const MF_DISABLED = &H2
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Long) As IntPtr
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr) As Integer
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean
Declare Function SendARP Lib "iphlpapi.dll" Alias "SendARP" (ByVal DestIP As Int32, ByVal SrcIP As Int32, ByVal pMacAddr() As Byte, ByRef PhyAddrLen As Int32) As Int32
#End Region
#Region " Network"
Public Shared Function GetMac(ByVal ipAddr As String) As String
Dim macAddress As String = String.Empty
Try
Dim destIP As Net.IPAddress = Net.IPAddress.Parse(ipAddr)
Dim IP() As Byte = destIP.GetAddressBytes()
Dim IPInt As Int32 = BitConverter.ToInt32(IP, 0)
Dim mac() As Byte = New Byte(5) {}
SendARP(IPInt, 0, mac, mac.Length)
macAddress = BitConverter.ToString(mac, 0, mac.Length)
Catch ex As Exception
Debug.Write(ex.Message)
End Try
Return macAddress
End Function
#End Region
#End Region
#Region " Main "
#Region " Call's , Others "
Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
Dim hMenu As IntPtr
Dim menuItemCount As Integer
hMenu = GetSystemMenu(hwnd, False)
menuItemCount = GetMenuItemCount(hMenu)
Call RemoveMenu(hMenu, menuItemCount - 1, MF_DISABLED Or MF_BYPOSITION)
Call RemoveMenu(hMenu, menuItemCount - 2, MF_DISABLED Or MF_BYPOSITION)
Call DrawMenuBar(hwnd)
End Sub
Private Sub gateway1()
Dim gatewayip As String
Dim i As Integer = 0
Dim arr(1) As String
Dim myNetworkAdapters() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces
Dim myAdapterProps As IPInterfaceProperties = Nothing
Dim myGateways As GatewayIPAddressInformationCollection = Nothing
For Each adapter As NetworkInterface In myNetworkAdapters
myAdapterProps = adapter.GetIPProperties
myGateways = myAdapterProps.GatewayAddresses
For Each Gateway As GatewayIPAddressInformation In myGateways
gatewayip = Gateway.Address.ToString
arr(1) = gatewayip
'MessageBox.Show("Gateway IP: " & Gateway.Address.ToString)
Next
Next
'MsgBox(arr(0))
WebBrowser1.Navigate(arr(1))
End Sub
#End Region
#Region "Buttons"
Private Sub DisplayMACAddress_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayMACAddress.Click
Me.MACAddressDisplayLabel.Text = GetMac(Me.MacLocalIPAddressBox.Text)
End Sub
Private Sub RouterLogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RouterLogIn.Click
gateway1()
Dim voice As New SpVoice
voice.Speak("Router Login , Security alert!")
End Sub
#End Region
#Region " Load"
Private Sub Network_Info_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
On Error Resume Next
Security.Enabled = True
DisableCloseButton(Me.Handle)
End Sub
#End Region
#Region " Timer's"
Private Sub Speech_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Speech.Tick
On Error Resume Next
Dim voice As New SpVoice
If voice.Speak("This Is Where, Your Local Machine, IP Address, is Displayed") Then
voice.Speak("Local Port Number, Is Displayed")
voice.Speak("Interenet,Service ,Provider ,IP Address, is Displayed ")
voice.Speak("To Log In To Your, Router, Please Press, Router Login , and Enter ,Username and Password")
Speech.Enabled = False
End If
End Sub
Private Sub Security_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Security.Tick
On Error Resume Next
Dim req As Net.HttpWebRequest = Net.WebRequest.Create("http://whatismyip.com/automation/n09230945.asp")
On Error Resume Next
Dim res As Net.HttpWebResponse = req.GetResponse
On Error Resume Next
Dim Stream As Stream = res.GetResponseStream()
On Error Resume Next
Dim sr As StreamReader = New StreamReader(Stream)
On Error Resume Next
RealIPAddressBox.Text = (sr.ReadToEnd())
On Error Resume Next
LocalMachineIPAddressBox.Text = AxWinsock1.LocalIP
On Error Resume Next
IPLocalPortBox.Text = AxWinsock1.LocalPort
On Error Resume Next
MaximizeBox = False
On Error Resume Next
Speech.Enabled = True
On Error Resume Next
Security.Enabled = False
End Sub
#End Region
#End Region
Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click
Me.Close()
End Sub
End Class[/CODE]