|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GetMac addressIn vb.net how do I get the mac address of my Nic card.
There are 6 total nic's in my pc, the mac that I'm looking for belongs to the network adapter that has the description Intel(R) PRO/1000 MT Network Connection - Packet Scheduler Miniport Any ideas? Thanks You could use WMI and do something similar to the following:
Private Function MacAttack() 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("IPEnabled").ToString) = True.ToString Then 'Environment.UserName Then 'MsgBox(mo.Item("MacAddress").ToString) Try MacAttack = (mo.Item("MacAddress").ToString) Catch ex As Exception End Try End If Next End Function Then I suppose I can do a
("Select * from Win32_NetworkAdapterConfiguration Where Description = "Intel(R) PRO/1000 MT Network Connection - Packet Scheduler Miniport") ????? Show quoteHide quote "Shawn" <TechniSh***@gmail.com> wrote in message news:1139950745.672398.269440@o13g2000cwo.googlegroups.com... > You could use WMI and do something similar to the following: > > Private Function MacAttack() 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("IPEnabled").ToString) = True.ToString Then > 'Environment.UserName Then > 'MsgBox(mo.Item("MacAddress").ToString) > Try > MacAttack = (mo.Item("MacAddress").ToString) > Catch ex As Exception > > End Try > End If > Next > End Function > Will this also retrieve wireless ethernet card MAC's?
-- Show quoteHide quoteDennis in Houston "Shawn" wrote: > You could use WMI and do something similar to the following: > > Private Function MacAttack() 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("IPEnabled").ToString) = True.ToString Then > 'Environment.UserName Then > 'MsgBox(mo.Item("MacAddress").ToString) > Try > MacAttack = (mo.Item("MacAddress").ToString) > Catch ex As Exception > > End Try > End If > Next > End Function > > Yes
Dennis wrote: Show quoteHide quote > Will this also retrieve wireless ethernet card MAC's? > -- > Dennis in Houston > > > "Shawn" wrote: > > > You could use WMI and do something similar to the following: > > > > Private Function MacAttack() 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("IPEnabled").ToString) = True.ToString Then > > 'Environment.UserName Then > > 'MsgBox(mo.Item("MacAddress").ToString) > > Try > > MacAttack = (mo.Item("MacAddress").ToString) > > Catch ex As Exception > > > > End Try > > End If > > Next > > End Function > > > > Thanks.
-- Show quoteHide quoteDennis in Houston "Shawn" wrote: > Yes > > > Dennis wrote: > > Will this also retrieve wireless ethernet card MAC's? > > -- > > Dennis in Houston > > > > > > "Shawn" wrote: > > > > > You could use WMI and do something similar to the following: > > > > > > Private Function MacAttack() 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("IPEnabled").ToString) = True.ToString Then > > > 'Environment.UserName Then > > > 'MsgBox(mo.Item("MacAddress").ToString) > > > Try > > > MacAttack = (mo.Item("MacAddress").ToString) > > > Catch ex As Exception > > > > > > End Try > > > End If > > > Next > > > End Function > > > > > > > > |
|||||||||||||||||||||||