Here is my problem, I can get a list of all the ethernet cards (mac
addresses) currently in the system however i have not found a way to easily
determine which card is for example a built in card and which one is a for
ex. PCMCIA card. My main problem is with laptops where there might be a
ethernet card built into the machine and the user might have plugged in
another ethernet card, at this point how do i make sure i look at the MAC
address of the built in ethernet card ? (I thought it would be the order
that they are enumarated by the system however this doesn't hold true for
all cases.
Also related to the above say you have a situation where the laptop has a
built in ethernet card but the docking station that this laptop goes into
also has another ethernet card how do you distinguish from these two in
order to find out the built in ethernet card ?
I use the Iphlpapi.dll with the following call: GetProcAddress(hLib,
"GetAdaptersInfo");
In order to get a list of ethernet cards and their information.
Thanks in advance for any suggestions.
Seymen
Best regards,
Rhett Gong [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
#define IP_LOCALHOST 0x0100007F
LPBYTE GetActiveMAC()
{
DWORD i, dwSize;
PMIB_IPADDRTABLE pAddr = NULL;
MIB_IFROW iInfo;
PFIXED_INFO pFI = NULL;
BYTE byMAC[6] = { 0, 0, 0, 0, 0, 0 };
// Get all IP addresses held by this machine; if it's connected to a
network, there's at least one
// that's not localhost
dwSize = 0;
GetIpAddrTable(NULL, &dwSize, TRUE);
pAddr = (PMIB_IPADDRTABLE)new BYTE[dwSize];
if (!GetIpAddrTable(pAddr, &dwSize, TRUE))
{
for (i = 0; i < pAddr->dwNumEntries; ++i)
{
if (IP_LOCALHOST != pAddr->table[i].dwAddr)
{
// Not localhost, so get the interface
memset(&iInfo, 0, sizeof(MIB_IFROW));
iInfo.dwIndex = pAddr->table[i].dwIndex;
GetIfEntry(&iInfo);
if (MIB_IF_TYPE_ETHERNET == iInfo.dwType)
{
//iInfo.bPhysAddr contains the MAC address of this
interface
memcpy(&byMAC, iInfo.bPhysAddr, iInfo.dwPhysAddrLen);
delete[] (LPBYTE)pAddr;
return byMAC;
}
}
}
}
delete[] (LPBYTE)pAddr;
return NULL;
}
"Seymen Ertas" <sey...@nospam.com> wrote in message
news:ueGEEQa...@TK2MSFTNGP10.phx.gbl...