473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Get active mac-address

hi,
i use this function to get the all mac adresses
how can i modify this function to get only the active connection.
Public Function GetMacAddress() As String

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 CBool(mo.Item("IPEnabled")) = True Then

MessageBox.Show("MAC address " & mo.Item("MacAddress").ToString())

End If

Next

End Function

Nov 21 '05 #1
2 4938
Hi

Try this.

' Add a Reference to System.Management
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject
moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_NetworkAdapter Where AdapterTypeID = 0")
moReturn = moSearch.Get
For Each mo In moReturn
Dim strOut As String
strOut = String.Format("Name {0} - Address {1}", mo("Name"),
mo("MacAddress"))
Trace.WriteLine(strOut)
Next

Ken
----------------------------------
"Stefan" <st@nospam.com> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
hi,
i use this function to get the all mac adresses
how can i modify this function to get only the active connection.
Public Function GetMacAddress() As String
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 CBool(mo.Item("IPEnabled")) = True Then
MessageBox.Show("MAC address " & mo.Item("MacAddress").ToString())
End If
Next
End Function
Nov 21 '05 #2
Ken,
appreciate your help but
all the adapters are returned
not just the active one (active one: the one i use to get on the network)

kind regards,

Stefan

"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:Ot**************@TK2MSFTNGP11.phx.gbl...
Hi

Try this.

' Add a Reference to System.Management
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject
moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_NetworkAdapter Where AdapterTypeID = 0")
moReturn = moSearch.Get
For Each mo In moReturn
Dim strOut As String
strOut = String.Format("Name {0} - Address {1}", mo("Name"),
mo("MacAddress"))
Trace.WriteLine(strOut)
Next

Ken
----------------------------------
"Stefan" <st@nospam.com> wrote in message
news:uA**************@TK2MSFTNGP09.phx.gbl...
hi,
i use this function to get the all mac adresses
how can i modify this function to get only the active connection.
Public Function GetMacAddress() As String
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 CBool(mo.Item("IPEnabled")) = True Then
MessageBox.Show("MAC address " & mo.Item("MacAddress").ToString())
End If
Next
End Function

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Little Squid | last post by:
Hello, From a PHP webpage, is it possible to authenticate users running Apache on MacOS X (with PHP 4) and an active directory on Windows 2000 or Windows XP? TIA, LS.
9
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk...
0
by: spe.stani.be | last post by:
SPE (Stani's Python Editor) is an open-source python IDE with auto indentation & completion, call tips, syntax coloring & highlighting, UML diagrams, class explorer, source index, auto todo list,...
5
by: Larry | last post by:
I'm currently using designMode in a page, and it's been working for IE6 on Windows, but I'm hearing complaints that it's not working on IE6 on Mac. I had done some research on this before deciding...
34
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
0
by: krisshnaprabhu | last post by:
Hi, I had done all the things now I can be able to retrieve the information from Active Directory when I login by using the IE(windows), if I get login through firefox through windows & Mac(Apple)...
2
by: petermichaux | last post by:
Hi, I don't know if there is a way to feature detect for this or not. I have a list and the user can click on items to select. I would like that they can command-click on Mac or control-click on...
1
Chittaranjan
by: Chittaranjan | last post by:
Hi All, I have a problem installing Active Perl on MAC System. Can any one help me what are the most important points I need to follow while installing Active Perl in a MAC System. If possible...
1
by: sweety_s | last post by:
I need to get the list of active threads in a process. I have used NtQuerySystemInformation API with SystemProcessInformation but i get all the no: of threads in the process, but i dont get the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.