效果如下:
具體代碼如下:
#include <Windows.h> #include <IPHlpApi.h> #include <stdio.h> comment(lib, "IPHlpApi") comment(lib, "ws2_32") main( argc, ** PIP_ADAPTER_INFO pAdapterInfo = ULONG ulLen = szBuffer[ pAdapterInfo = (PIP_ADAPTER_INFO)HeapAlloc(GetProcessHeap(), , (NULL == printf( (ERROR_BUFFER_OVERFLOW == GetAdaptersInfo(pAdapterInfo, & HeapFree(GetProcessHeap(), pAdapterInfo = (PIP_ADAPTER_INFO)HeapAlloc(GetProcessHeap(), (NULL == printf( (ERROR_SUCCESS != GetAdaptersInfo(pAdapterInfo, & printf( (NULL == printf( SetConsoleTitle(TEXT( printf(, pAdapterInfo-> printf(, pAdapterInfo-> printf(, pAdapterInfo-> printf( (size_t i = ; i < pAdapterInfo->AddressLength; i++ (i == (pAdapterInfo->AddressLength - printf(, ()pAdapterInfo-> printf(, ()pAdapterInfo-> printf( printf(, pAdapterInfo-> printf( (pAdapterInfo-> MIB_IF_TYPE_OTHER:printf(); MIB_IF_TYPE_ETHERNET:printf(); MIB_IF_TYPE_TOKENRING:printf(); MIB_IF_TYPE_FDDI:printf(); MIB_IF_TYPE_PPP:printf(); MIB_IF_TYPE_LOOPBACK:printf(); MIB_IF_TYPE_SLIP:printf(); :printf(, pAdapterInfo->Type); printf(, pAdapterInfo-> printf(, pAdapterInfo-> printf(, pAdapterInfo-> (pAdapterInfo-> printf( printf(, pAdapterInfo-> printf( error = _localtime32_s(&newtime, (__time32_t*)&pAdapterInfo-> printf( error = asctime_s(szBuffer, , & printf( printf( printf( error = _localtime32_s(&newtime, (__time32_t*)&pAdapterInfo-> printf( error = asctime_s(szBuffer, , & printf( printf( printf( (pAdapterInfo-> printf( printf(, pAdapterInfo-> printf(, pAdapterInfo-> printf( printf( pAdapterInfo = pAdapterInfo-> } HeapFree(GetProcessHeap(), }