|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get IP AddressI've 4 nic's in my pc, and through the code beloew I'm able to get mac address of the nic that I want. now how do I get the IP address of that NIC? Dim MacAddress As String Dim scope As ManagementScope = New ManagementScope(ManagementPath.DefaultPath) Dim query As SelectQuery = New SelectQuery("Win32_NetworkAdapterConfiguration") ' this query returns all properties of the class Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher(scope, query) Dim mo As New ManagementObject For Each mo In searcher.Get() If (mo.Item("Caption").ToString) = "[00000016] Packet Scheduler Miniport" Then Try MacAddress = (mo.Item("MacAddress").ToString) Me.RichTextBox1.Text &= "Mac Address: " & MacAttack & vbCrLf Catch ex As Exception End Try End If Next Thanks Hi,
this function will give you the IP of the "first" nic Private Function GetIP() As String Dim ComputerName As String = System.Net.Dns.GetHostName Dim Host As System.Net.IPHostEntry Dim HostAddresses() As System.Net.IPAddress Host = System.Net.Dns.GetHostEntry(ComputerName) HostAddresses = Host.AddressList Return HostAddresses(0).ToString End Function All IPs are within "HostAddresses" Hope this helped, Josef Show quoteHide quote "Jason" <ja***@someone.com> schrieb im Newsbeitrag news:%23PSM1%23iNGHA.1028@TK2MSFTNGP11.phx.gbl... > Hello > > I've 4 nic's in my pc, and through the code beloew I'm able to get mac > address of the nic that I want. now how do I get the IP address of that > NIC? > > Dim MacAddress As String > Dim scope As ManagementScope = New > ManagementScope(ManagementPath.DefaultPath) > Dim query As SelectQuery = New > SelectQuery("Win32_NetworkAdapterConfiguration") > ' this query returns all properties of the class > Dim searcher As ManagementObjectSearcher = New > ManagementObjectSearcher(scope, query) > Dim mo As New ManagementObject > For Each mo In searcher.Get() > If (mo.Item("Caption").ToString) = "[00000016] Packet Scheduler > Miniport" Then > Try > MacAddress = (mo.Item("MacAddress").ToString) > Me.RichTextBox1.Text &= "Mac Address: " & MacAttack & > vbCrLf > Catch ex As Exception > > End Try > End If > Next > > > Thanks > > > If you are using VB 2005, you could try this:
/// Imports System.Net.NetworkInformation Dim allInterfaces() as NetworkInterface Dim aInterface as NetworkInterface allInterfaces = NetworkInterface.GetAllNetworkINterfaces() For Each aInterface In allInterfaces Dim ipAddress as String = aInterface.GetIPProperties.UnicastAddresses(0).Address.ToString Dim macAdd as String = aInterface.GetPhysicalAddress.ToString Next // Hope it helps. --Simon Show quoteHide quote "Jason" <ja***@someone.com> wrote in message news:%23PSM1%23iNGHA.1028@TK2MSFTNGP11.phx.gbl... > Hello > > I've 4 nic's in my pc, and through the code beloew I'm able to get mac > address of the nic that I want. now how do I get the IP address of that > NIC? > > Dim MacAddress As String > Dim scope As ManagementScope = New > ManagementScope(ManagementPath.DefaultPath) > Dim query As SelectQuery = New > SelectQuery("Win32_NetworkAdapterConfiguration") > ' this query returns all properties of the class > Dim searcher As ManagementObjectSearcher = New > ManagementObjectSearcher(scope, query) > Dim mo As New ManagementObject > For Each mo In searcher.Get() > If (mo.Item("Caption").ToString) = "[00000016] Packet Scheduler > Miniport" Then > Try > MacAddress = (mo.Item("MacAddress").ToString) > Me.RichTextBox1.Text &= "Mac Address: " & MacAttack & > vbCrLf > Catch ex As Exception > > End Try > End If > Next > > > Thanks > > >
Eval function vb.net
Best data structure? empty GUID from string in VB2005 Changing CheckedState or Checked-value without raising ItemChecked-event Installing published application fails MyApplication has encountered a problem... when not Administrator! Create object through classname How to change "database and User" into CR9 Webservice Opacity Unable to open file |
|||||||||||||||||||||||