?
Solved

What determines the MAC detection order from machine to machine?

Posted on 2009-04-30
4
Medium Priority
?
169 Views
Last Modified: 2013-12-17
The code I have included polls my machine and returns all of the MAC addresses it finds.  On my machine it consistently finds the wireless card first followed by the Ethernet card.  Is this the case on all machines?  Is there a way to specify one over the other?  Thank you.
private List<string> getMacAddys()
{
     List<string> physical_addys = new List<string>();
 
     NetworkIUnterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
     
     foreach ( NetworkInterface obj in interfaces )
          physical_addys.Add(ni.GetPhysicalAddress().ToString());
 
     return physical_addys;
}

Open in new window

0
Comment
Question by:Yeggmeister
  • 2
  • 2
4 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 2000 total points
ID: 24270784
I don't see any overloads for that method, but on the individual interfaces in each slot of the array, you can query the type:
private List<string> getMacAddys()
{
    List<string> physical_addys = new List<string>();
 
    NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
 
    foreach (NetworkInterface ni in interfaces)
    {
        if (ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
        {
            physical_addys.Add(ni.GetPhysicalAddress().ToString());
        }
    }
 
    return physical_addys;
}

Open in new window

0
 

Author Comment

by:Yeggmeister
ID: 24275814
Thank you for the quick response!  This helped me tremendously.  My question, although it is strictly out of curiosity, still stands.  What determines the polling order?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24277282
I would imagine the OS has some internal list and the GetAllNetworkInterfaces() function receives an iterator to the beginning of the list and steps through--the OS probably has some manner of managing how this list is ordered. Vague enough for you :)

Please don't take this as the final word on the issue as I am just hypothesizing.
0
 

Accepted Solution

by:
Yeggmeister earned 0 total points
ID: 24277967
Thank you again.  I am going to mark this question / thread as completed as my code is now working.  I hope at some point someone else can add more to it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question