#include <Iphlpapi.h> #pragma comment(lib, "Iphlpapi.lib") // Get and print information from IP_ADDR_STRING structure. void PrintIPs(PIP_ADDR_STRING pCurIP, bool bFullInf, CString &strADDRList) { strADDRList = ""; if (pCurIP->IpAddress.String[0] == '\0') { strADDRList = "not presented\n\n"; return; } CString strTemp; if (bFullInf) { do { strTemp.Format("IP Addr:[%s] Subnet Mask:[%s]\r\n", pCurIP->IpAddress.String, pCurIP->IpMask.String[0] == '\0' ? "no" : pCurIP->IpMask.String); strADDRList += strTemp; } while ((pCurIP = pCurIP->Next) != NULL); } else { do { strTemp.Format("%s ", pCurIP->IpAddress.String); strADDRList += strTemp; } while ((pCurIP = pCurIP->Next) != NULL); }}
DWORD GetAdaptersInfo( PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen );Client: Included in Windows XP, Windows 2000 Professional, Windows Me, and Windows 98. Server: Included in Windows Server 2003 and Windows 2000 Server. Header: Declared in Iphlpapi.h. Library: Use Iphlpapi.lib.
#pragma comment(lib, "Iphlpapi.lib") // Get and print information from IP_ADDR_STRING structure.
void PrintIPs(PIP_ADDR_STRING pCurIP, bool bFullInf, CString &strADDRList)
{
strADDRList = "";
if (pCurIP->IpAddress.String[0] == '\0')
{
strADDRList = "not presented\n\n";
return;
}
CString strTemp;
if (bFullInf)
{
do
{
strTemp.Format("IP Addr:[%s] Subnet Mask:[%s]\r\n",
pCurIP->IpAddress.String,
pCurIP->IpMask.String[0] == '\0' ? "no" : pCurIP->IpMask.String);
strADDRList += strTemp;
} while ((pCurIP = pCurIP->Next) != NULL);
}
else
{
do
{
strTemp.Format("%s ", pCurIP->IpAddress.String);
strADDRList += strTemp;
} while ((pCurIP = pCurIP->Next) != NULL);
}}
PIP_ADAPTER_INFO pAdapterInfo,
PULONG pOutBufLen
);Client: Included in Windows XP, Windows 2000 Professional, Windows Me, and Windows 98.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Header: Declared in Iphlpapi.h.
Library: Use Iphlpapi.lib.