Network Adapter MAC address code snippet 
Author Message
 Network Adapter MAC address code snippet

After viewing a number of messages this code seems to work :)

Imports System.Management

Module Module1

Sub Main()

Dim mc As System.Management.ManagementClass

Dim mo As ManagementObject

mc = New ManagementClass("Win32_NetworkAdapterConfiguration")

Dim moc As ManagementObjectCollection = mc.GetInstances()

For Each mo In moc

If mo.Item("IPEnabled") = True Then

MsgBox("MAC address " & mo.Item("MacAddress").ToString())

End If

Next

End Sub

End Module



Thu, 02 Sep 2004 02:53:47 GMT  
 Network Adapter MAC address code snippet
Don't forget to ...
Right click on the project name in the solution explorer and add a reference
to the system.manager component.


Thu, 02 Sep 2004 03:24:00 GMT  
 Network Adapter MAC address code snippet
Or,

Imports System.Management
Module Module1

Sub Main()

Dim oQuery As New SelectQuery("SELECT MacAddress FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")
Dim oResults As New ManagementObjectSearcher(oQuery)
Dim oItem As ManagementObject

For Each oItem In oResults.Get()
    MsgBox("MAC address " & oItem.Properties("MacAddress").ToString())
Next

End Sub

End Module


Quote:
> After viewing a number of messages this code seems to work :)

> Imports System.Management

> Module Module1

> Sub Main()

> Dim mc As System.Management.ManagementClass

> Dim mo As ManagementObject

> mc = New ManagementClass("Win32_NetworkAdapterConfiguration")

> Dim moc As ManagementObjectCollection = mc.GetInstances()

> For Each mo In moc

> If mo.Item("IPEnabled") = True Then

> MsgBox("MAC address " & mo.Item("MacAddress").ToString())

> End If

> Next

> End Sub

> End Module



Tue, 07 Sep 2004 01:58:51 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Network adapter question: how to put ip address and MAC addresses together

2. Ip and MAC address for each network adapter?

3. Need to Retrieve Network Adapters MAC Address

4. Network adapter MAC address

5. List and modify Network Adapter Info based on MAC range

6. retrieve network adapter address on a PC from VB6

7. network adapter address

8. retrieve network adapter address on a PC from VB6

9. network adapter address

10. Problems finding correct IP address using WINSOCK Control with 2 network adapters

11. Accessing the IP address of multiple network adapters using the MS Winsock Control

12. Accessinf the IP address of multiple network adapters using the MS Winsock Control

 

 
Powered by phpBB® Forum Software