What adapter/interface am I using?
Posted on 2009-05-04
I am writing some code that will sit on different Windows machines, and I will need to determine my:
- ether address (physical)
- broadcast IP
Now, I know I can system out and use ipconfig to gather most of this info (and calculate the rest), but the problem I am having is which adapter to use.
I would like to guarantee that I am using the WIRED adapter that is accessible on the LAN, or failing that, the default adapter. I need to assume that the machine I am sitting on may have multiple adapters, and this could be a mix of wired, wireless, etc...
I have tried using gethostbyname, as well as WSAIoct with SIO_GET_INTERFACE_LIST, but I do not know if the information returned by these functions can be used to determine if an adapter is wired or if it is the default.