Hi akayoku!
I'm working on a school project to make a security program. I need to
get the MAC Address from the computer. That is the "Physical Address"
when you type "ipconfig/all" in MSDOS command prompt.
See: How To Get the MAC Address for an Ethernet Adapter
http://support.microsoft.com/kb/118623/en-us
Or try this one:
<code>
CString GetMACAddress(int adapternumber)
{
int nAdapterCount = 0;
ULONG ip;
ULONG buflen;
PIP_ADAPTER_INFO pAdInfo = NULL;
PIP_ADAPTER_INFO pAdInfo_c = NULL;
buflen = 0;
GetAdaptersInfo(pAdInfo, &buflen); //since buflen=0, buffer is
// too small. function returns required buffersize in buflen.
pAdInfo = (struct _IP_ADAPTER_INFO *)new UCHAR[buflen+1];
pAdInfo_c = pAdInfo;
if (GetAdaptersInfo(pAdInfo, &buflen) == ERROR_SUCCESS)
{
do
{
ip = inet_addr(pAdInfo->IpAddressLi*st.IpAddress.String);
if ((ip != 0)&&(ip != 0x7f000001))
{
nAdapterCount++;
if ((nAdapterCount == adapternumber)||(adapternumber == 0))
{
if (pAdInfo->AddressLength != 0)
{
CString macstr;
for (int i = 0; i < (int)pAdInfo->AddressLength; i++)
{
CString temp;
temp.Format(_T(" %02X"), pAdInfo->Address[i]);
macstr += temp;
}
delete pAdInfo;
return macstr;
}
}
}
} while ((pAdInfo->Next != NULL)&&((pAdInfo = pAdInfo->Next) !=
pAdInfo));
}
delete pAdInfo_c;
return _T("");
}
</code>
--
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/