#pragma comment(lib,"Iphlpapi.lib")
{
char szDeviceName[128]; // 名字
char szIPAddrStr[16]; // IP
char szHWAddrStr[18]; // MAC
DWORD dwIndex; // 编号
bool filled;//是否取得了网卡信息
}INFO_ADAPTER, *PINFO_ADAPTER;
{
char tempChar;
ULONG uListSize=1;
PIP_ADAPTER_INFO pAdapter; // 定义PIP_ADAPTER_INFO结构存储网卡信息
int nAdapterIndex = 0;
if (dwRet == ERROR_BUFFER_OVERFLOW)
{
PIP_ADAPTER_INFO pAdapterListBuffer = (PIP_ADAPTER_INFO)new(char[uListSize]);
dwRet = GetAdaptersInfo(pAdapterListBuffer, &uListSize);
if (dwRet == ERROR_SUCCESS)
{
pAdapter = pAdapterListBuffer;
while (pAdapter) // 枚举网卡
{
CString strTemp;
//strTemp.Format(_T("%s"),pAdapter->AdapterName); // 网卡名字
//strTemp = CString("//Device//NPF_") + strTemp; // 加上前缀
//strcpy(AdapterList[nAdapterIndex].szDeviceName,strTemp);
//strcpy(AdapterList[nAdapterIndex].szIPAddrStr, pAdapter->IpAddressList.IpAddress.String );// IP
FormatMACToStr( AdapterList[nAdapterIndex].szHWAddrStr,pAdapter->Address ); // MAC!
AdapterList[nAdapterIndex].dwIndex = pAdapter->Index; // 编号
AdapterList[nAdapterIndex].filled = true;
pAdapter = pAdapter->Next;
nAdapterIndex ++;
}
delete pAdapterListBuffer;
}
}
}
{
int i;
short temp;
char szStr[3];
strcpy(lpHWAddrStr, "");
for (i=0; i<6; ++i)
{
temp = (short)(*(HWAddr + i));
_itoa(temp, szStr, 16);
if (strlen(szStr) == 1) strcat(lpHWAddrStr, "0");
strcat(lpHWAddrStr, szStr);
// if ( i < 5 ) strcat(lpHWAddrStr, "-"); // 加上 -
}
}
373




被折叠的 条评论
为什么被折叠?



