为什么还用这个过时的netbios函数?用IpHelper函数不是很好吗,在win2000
下面我编的一个C++的Console程序:
#define _WIN32_WINNT 0x0500
#include <stdio.h>
#include <windows.h>
#include <Iphlpapi.h>
#pragma comment(lib, "Iphlpapi")
void main()
{
DWORD ret, dwSize;
IP_ADAPTER_INFO pTemp[10], *p;
dwSize = 10 * sizeof(IP_ADAPTER_INFO);
ret = GetAdaptersInfo(pTemp, &dwSize);
if(ret == ERROR_SUCCESS){
p = pTemp;
printf("OK/n");
for(unsigned int i=0; i<10; i++){
if(p == NULL)
break;
printf("AdapterName : %s/n", p->AdapterName);
printf("Description : %s/n", p->Description);
printf("MAC Addr(%d): ", p->AddressLength);
for(unsigned int j=0; j < p->AddressLength; j++)
if(j != p->AddressLength-1)
printf("%.2X-", p->Address[j]);
else
printf("%.2X", p->Address[j]);
printf("/n");
printf("IP Addr : %s/n", p->IpAddressList.IpAddress.String);
p = p->Next;
printf("/n");
}
}
else
printf("FT %d/n", GetLastError());
}