使用api http://www.programfan.com/showarticle.asp?id=2248------------------------------------
分应该给我吧 哈哈
分应该给我吧 哈哈
解决方案 »
- 如何在PictureBox中绘制矢量图形,并且可以进行放大、旋转之类的处理?
- 一套原创的sqlserver通用分页方案 忘高人测试效率 先阿里嘎多了
- 如何用listview显示图片
- 如何将这样的字符串按千分位显示?
- 为什么int i不能在page_load中申明而必须在class下申明?
- 有没有作用和EXIST一样,但不用考虑权限的C#函数?
- 请问在一个框架向另一个框架document.write(字符串),怎样实现!!
- 请教使用PCSC SCardTransmit向卡片发送指令失败的问题
- 在windows里怎么获得web的文件
- 多次点击按钮才能关闭窗体如何解决
- 请问在.net怎样判断是否连接上了网?
- web项目创建时出现错误,请帮忙!
private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip); static private Int64 getRemoteMAC(string remoteIP)
{
Int32 ldest= inet_addr(remoteIP); //目的地的ip try
{
Int64 macinfo = new Int64();
Int32 len = 6;
int res = SendARP(ldest,0, ref macinfo, ref len);
return macinfo;
}
catch(Exception err)
{
Console.WriteLine("Error:{0}",err.Message);
}
return 0;
}
public static string GetMacAddress(string hostname)
{
string HumanReadableMac=string.Empty;
string tmpHumanReadableMac=string.Empty;
try
{
Int64 mac=getRemoteMAC(hostname);
tmpHumanReadableMac=Convert.ToString(mac,16);
for(int i=0;i<tmpHumanReadableMac.Length;i=i+2)
{
HumanReadableMac=tmpHumanReadableMac.Substring(i,2)+HumanReadableMac;
}
}
catch(System.Exception ee)
{
string errMsg
="获取"
+hostname
+"的mac的时候\n发生错误:"
+ee.Message
+"\n原始mac为:"
+tmpHumanReadableMac;
System.Windows.Forms.MessageBox.Show(errMsg);
}
return HumanReadableMac; }
将返回的是网关的Mac~