如何在C#中找到网卡地址

huguo0838 2005-01-21 11:35:54

新手请教:
如何在C#中找到网卡地址?如何找到cpu、硬盘序列号?
...全文
185 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
topycsdn 2005-01-23
  • 打赏
  • 举报
回复
楼上的都说了```
c11_11_11 2005-01-23
  • 打赏
  • 举报
回复
[DllImport("Iphlpapi.dll")]
public static extern int SendARP (Int32 dest,Int32 host,ref Int64 mac,ref Int32 length);//dest为目标机器的IP;Host为本机器的IP

[DllImport("Ws2_32.dll")]
public static extern Int32 inet_addr (string ip);

private void button1_Click(object sender, System.EventArgs e)
{

string s;
this.button1.Enabled=false;

IPHostEntry myin=Dns.GetHostByName(System.Environment.MachineName);
MessageBox.Show(myin.HostName.ToString());
MessageBox.Show(myin.AddressList[0].ToString());
Int32 mysource=inet_addr(myin.AddressList[0].ToString());
Int32 iptest=inet_addr(myin.AddressList[0].ToString());


Int64 macinfo=new Int64();
Int32 len=6;
SendARP(iptest,mysource,ref macinfo,ref len);

s=System.Convert.ToString(macinfo,16);
MessageBox.Show(s.ToString());
return;
string[] b=new string[6];
string box;
int l=12;
for(int i=0;i<6;i++)
{
b[i]=s.Substring(l-2,2);
l-=2;

}
box=b[0];
for(int j=1;j<6;j++)
{
box=box+"-"+b[j];
}

this.textBox2.Text=box;





}

huguo0838 2005-01-23
  • 打赏
  • 举报
回复
感谢dazhu2(边城浪子
huguo0838 2005-01-23
  • 打赏
  • 举报
回复
真诚感谢eagle40(老鹰)
egxsun 2005-01-22
  • 打赏
  • 举报
回复
用WMI
flyye_cs 2005-01-22
  • 打赏
  • 举报
回复
Search WMI (Windows Management Instrumentation) ...
老鹰40 2005-01-21
  • 打赏
  • 举报
回复
关注...
dazhu2 2005-01-21
  • 打赏
  • 举报
回复
获取MAC的API::
[DllImport("Iphlpapi.dll")]
public static extern int SendARP (Int32 dest,Int32 host,ref Int64 mac,ref Int32 length);//dest为目标机器的IP;Host为本机器的IP

[DllImport("Ws2_32.dll")]
public static extern Int32 inet_addr (string ip);

private void button1_Click(object sender, System.EventArgs e)
{

string s;
this.button1.Enabled=false;

IPHostEntry myin=Dns.GetHostByName(System.Environment.MachineName);
MessageBox.Show(myin.HostName.ToString());
MessageBox.Show(myin.AddressList[0].ToString());
Int32 mysource=inet_addr(myin.AddressList[0].ToString());
Int32 iptest=inet_addr(myin.AddressList[0].ToString());


Int64 macinfo=new Int64();
Int32 len=6;
SendARP(iptest,mysource,ref macinfo,ref len);

s=System.Convert.ToString(macinfo,16);
MessageBox.Show(s.ToString());
return;
string[] b=new string[6];
string box;
int l=12;
for(int i=0;i<6;i++)
{
b[i]=s.Substring(l-2,2);
l-=2;

}
box=b[0];
for(int j=1;j<6;j++)
{
box=box+"-"+b[j];
}

this.textBox2.Text=box;





}


获取CPU等的信息的API不记得了,要查资料

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧