typedef struct arpPacket
{
 EHHDRehhdr;
 ARPHDRarphdr;
} ARPPACKET, *PARPPACKET;
#pragma pack(pop)
int main(int argc, char *argv[])
{
 static char AdapterList[Max_Num_Adapter][1024];
 char szPacketBuf[600];
 char MacAddr[6];
 LPADAPTERlpAdapter;
 LPPACKETlpPacket;
 WCHARAdapterName[2048];
 WCHAR *temp, *temp1;
 ARPPACKET ARPPacket;
 ULONG AdapterLength = 1024;
 
 int AdapterNum = 0;
 int nRetCode, i;
 //Get The list of Adapter
 if (PacketGetAdapterNames((char*)AdapterName, &AdapterLength) == FALSE)
 {
  printf("Unable to retrieve the list of the adapters!\n");
  return 0;
 }
 temp = AdapterName;
 temp1 = AdapterName;
 i = 0;
 while ((*temp != '\0') || (*(temp - 1) != '\0'))
 {
  if (*temp == '\0')
  {
   memcpy(AdapterList[i], temp1, (temp - temp1) *2);
   temp1 = temp + 1;
   i++;
  }
  temp++;
 }
 AdapterNum = i;
 for (i = 0; i < AdapterNum; i++)
  wprintf(L "\n%d- %s\n", i + 1, AdapterList[i]);
  printf("\n");
 //Default open the 0
 lpAdapter = (LPADAPTER)PacketOpenAdapter((LPTSTR)AdapterList[0]);
 //取第一个网卡
 if (!lpAdapter || (lpAdapter->hFile == INVALID_HANDLE_VALUE))
 {
  nRetCode = GetLastError();
  printf("Unable to open the driver, Error Code : %lx\n", nRetCode);
  return 0;
 }
 lpPacket = PacketAllocatePacket();
 if (lpPacket == NULL)
 {
  printf("\nError:failed to allocate the LPPACKET structure.");
  return 0;
 }