Get your MAC(Media Access Control) using VB.Net 08-15-2013, 04:00 PM
#1
Get your Media Access Control (Machine Address) using your own program. What I really means is 100% Virus free program. You can either use the program which I already compiled or Copy the Source code and build your own application and use that.
![[Image: ZoSoftMACP.png]](http://www.zosoftnet.com/wp-content/uploads/2012/03/ZoSoftMACP.png)
Download the binary file : http://www.zosoftnet.com/wp-content/uplo...ddress.zip
![[Image: ZoSoftMACP.png]](http://www.zosoftnet.com/wp-content/uploads/2012/03/ZoSoftMACP.png)
Download the binary file : http://www.zosoftnet.com/wp-content/uplo...ddress.zip
PHP Code:
Imports System.Management
Imports System.Net
Public Class Form1
Dim mos As ManagementObjectSearcher
Dim moc As ManagementObjectCollection
Dim mo As ManagementObject = Nothing
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
Try
TextBox1.Clear()
mos = New ManagementObjectSearcher("select * from Win32_NetworkAdapter where Name='" + ComboBox1.SelectedItem.ToString() + "'")
moc = mos.Get()
If (moc.Count > 0) Then
For Each mo In moc
TextBox1.Text = mo.Item("MACAddress").ToString
Next
End If
Catch ex As Exception
End Try
Try
TextBox2.Clear()
mos = New ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'")
moc = mos.Get
If moc.Count > 0 Then
For Each mo In moc
TextBox2.Text = mo.Item("DNSHostName").ToString
Next
End If
Catch ex As Exception
End Try
Try
'Extract IP address
Dim local As IPHostEntry
local = Dns.GetHostByName(TextBox2.Text)
Dim ip As IPAddress
TextBox3.Clear()
For Each ip In local.AddressList
If TextBox3.Text = "" Then
TextBox3.Text = ip.ToString
Else
TextBox3.Text = TextBox3.Text & " / " & ip.ToString
End If
Next
Catch ex As Exception
End Try
Try
TextBox4.Clear()
'SubNet Mask
If moc.Count > 0 Then
TextBox4.Text = mo.Item("IPSubnet")(0)
End If
Catch ex As Exception
End Try
Try
TextBox5.Clear()
mos = New ManagementObjectSearcher("SELECT * FROM Win32_NetworkClient WHERE Status = 'OK'")
moc = mos.Get
If moc.Count > 0 Then
For Each mo In moc
TextBox5.Text = mo.Item("Caption").ToString
Next
End If
Catch ex As Exception
End Try
Catch ex As Exception
Finally
mo.Dispose()
mos.Dispose()
moc.Dispose()
End Try
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Try
If MsgBox("Are you sure you want to exit?", MsgBoxStyle.YesNo, "Close?") = MsgBoxResult.No Then
e.Cancel = True
Else
e.Cancel = True
ClosingTimer.Enabled = True
End If
Catch ex As Exception
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
TextBox1.Clear()
mos = New ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapter Where AdapterType='Ethernet 802.3'")
moc = mos.Get
For Each mo In moc
ComboBox1.Items.Add(mo.Item("Name").ToString)
Next
Catch ex As Exception
MsgBox("Error : " & ex.ToString, MsgBoxStyle.Exclamation, "")
Finally
End Try
End Sub
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
Try
If e.Button = Windows.Forms.MouseButtons.Right Then
ContextMenuStrip1.Show(Me, Me.Cursor.Position.X - 250, Me.Cursor.Position.Y - 250)
End If
Catch ex As Exception
End Try
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
Try
MsgBox("This Application is designed and Programmed by : " & vbCrLf & "Mr. Vanlalruata Hnamte" & vbCrLf & "Copyrighted © ZoSoft Network 2011", MsgBoxStyle.Information, "About")
Catch ex As Exception
End Try
End Sub
Private Sub ClosingTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClosingTimer.Tick
Try
Me.Opacity = Me.Opacity - 0.1
If Me.Opacity <= 0 Then End
Catch ex As Exception
End Try
End Sub
End Class
![[Image: coolsignature.gif]](http://www.zosoftnet.com/coolsignature.gif)
:angel: