怎么用C++BUILDER编程列出局域网内同网段IP地址的所有MAC地址

如何用C++BUILDER编程列出局域网内同网段IP地址的所有MAC地址?
如何用C++BUILDER编程列出局域网内同网段IP地址的所有MAC地址?

------解决方案--------------------
#include "Unit1.h"
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------
#include "stdio.h"
#include "winsock2.h"
#include "iphlpapi.h"
#pragma comment(lib,"C:\Program Files\Borland\CBuilder6\Lib\Psdk\iphlpapi.lib")
String GetMAC(String IP) // 取IP的MAC
{
unsigned char mac[6];
ULONG MacLen=6;
ULONG DestIP=inet_addr(IP.c_str());
int rs=SendARP(DestIP,(ULONG)NULL,(PULONG)mac,(PULONG)&MacLen);
String MACs="";
if (rs==0)
{
char buf[32];
sprintf(buf,"%02x-%02x-%02x-%02x-%02x-%02x",
(unsigned int)mac[0],
(unsigned int)mac[1],
(unsigned int)mac[2],
(unsigned int)mac[3],
(unsigned int)mac[4],
(unsigned int)mac[5]);
MACs=buf;
}
return(MACs);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
for (int i=1;i<255;i++)
{
String ip=IP->Text+String(i); //IP->Text内容: 192.168.0.
String mac=GetMAC(ip);
if (mac=="")
mac="/";
Memo1->Lines->Add(ip+(char)9+mac);
Application->ProcessMessages();
if (Application->Terminated)
break;
}
}

------解决方案--------------------
ls的够了