Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Display MAC Address From Enterd Local Machines IP
Submitted:
5/14/2010
Version:
VB 2008
Compatibility:
VB 2008
Category:
Networking
Views:
20739
This Displays MAC Address, add 1 textbox call it MacLocalIPAddressBox and one label called MACAddressDisplayLabel. Then all you need to do is add the code below and add local machines ip addresss ie 192.168.1.1 then press the button and the label will display the mac address for each local machines ip.
Declarations:
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
Code:
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 Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click Me.MACAddressDisplayLabel.Text = GetMac(Me.MacLocalIPAddressBox.Text) End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement