#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include "IPhelper/Iphlpapi.h"
#pragma comment(lib, "IPhelper/IPHLPAPI.LIB")
DWORD dwLen = 0, dwError;
dwError = GetAdaptersInfo(NULL, &dwLen);
pIPHelper = (PIP_ADAPTER_INFO)malloc(dwLen);
dwError = GetAdaptersInfo(pIPHelper, &dwLen);
CString strMAC;
strMAC.Format("%02X-%02X-%02X-%02X-%02X-%02X", pIPHelper->Address[0],\
pIPHelper->Address[1], pIPHelper->Address[2], pIPHelper->Address[3],\
pIPHelper->Address[4], pIPHelper->Address[5]);
PIP_ADDR_STRING pAddrList = &pIPHelper->IpAddressList;
CString m_IpAddress ="";
while(pAddrList != NULL)
{
CString strAddr = pAddrList->IpAddress.String;
pAddrList = pAddrList->Next;
m_comAddr.AddString(strAddr);
}
CString strSubMask, strGateway;
strSubMask.Format("%s", pIPHelper->IpAddressList.IpMask.String);
strGateway.Format("%s", pIPHelper->GatewayList.IpAddress.String);
m_strMac = strMAC;
m_strSub = strSubMask;
m_strGate = strGateway;
m_comAddr.SetCurSel(0);
free(pIPHelper);