| 发表于:2007-01-11 13:11:018楼 得分:0 |
下面的做法参考一下。另外不需要255个线程,有一个线程扫描就可以了。255个线程光创建和调度就要消耗很多系统资源,可能是性能不高的一个原因哦! public class clsarp { #region apis [dllimport( "iphlpapi.dll ", callingconvention = callingconvention.cdecl)] private static extern int32 sendarp(uint32 udwdestip,uint32 udwsrcip,byte[] pmacaddr,ref int32 phyaddrlen); private const int32 number_of_physical_address_bytes = 6; #endregion public clsarp() { } public static byte[] getcomputermacaddr(uint32 dwip) { byte[] abmacaddr = null; int32 dwphyaddrlen = 0; try { abmacaddr = new byte[number_of_physical_address_bytes]; dwphyaddrlen = abmacaddr.length; if (sendarp(dwip,0,abmacaddr, ref dwphyaddrlen) != 0) { //get error!reset byte array to null abmacaddr = null; } } catch { abmacaddr = null; } return abmacaddr; } } | | |
|