Hi,
I need to check the MAC Adresses on my Computer.
I use the follwoing code and get alwys the follwing Error "error: cannot obtain value"
Dim strtemp As String
Dim bReturnValue As Boolean = True
Dim query As New SelectQuery("Win32_NetworkAdapter")
'ManagementObjectSearcher retrieves a collection of WMI objects based on
' the query.
Dim search As New ManagementObjectSearcher(query)
' Display each entry for Win32_bios
Dim info As ManagementObject
For Each info In search.Get()
strtemp = info("MacAddress").ToString()
If strtemp = MacAddress Then
bReturnValue = True
Exit For
End If
Next
I have no clue what the problem could be, Any good ideas?
Thanks
Bastian
Sibusisiwe Mketwa5 pointsPosted May 22, 2007, 12:11 AM EDT
Import the following namespace.
Imports System.Management
Declare following object variables.
Dim objMOS As ManagementObjectSearcher
Dim objMOC As Management.ManagementObjectCollection
Dim objMO As Management.ManagementObject
Execute the query.
objMOS = New ManagementObjectSearcher("Select * From Win32_NetworkAdapter")
objMOC = objMOS.Get
Get MAC address from the query result.
For Each objMO In objMOC
MessageBox.Show(objMO("MACAddress"))
Next
Dispose object variables.
objMOS.Dispose()
objMOS = Nothing
objMO.Dispose()
objMO = Nothing
Bastian3 pointsPosted May 23, 2007, 12:33 PM EDT
Thanks a lot, its funktioning.
Best Regards
Bastian