C#中通过SendARP读取MAC地址:

using System.Runtime.InteropServices;

publicstaticstring GetMacBySendARP(string remoteIP)
{
StringBuilder macAddress =new StringBuilder(); try
{
Int32 remote = inet_addr(remoteIP); Int64 macInfo =new Int64();
Int32 length =;
SendARP(remote, , ref macInfo, ref length); string temp = Convert.ToString(macInfo, ).PadLeft(, '').ToUpper(); int x =;
for (int i =; i <; i++)
{
if (i ==)
{
macAddress.Append(temp.Substring(x -, ));
}
else
{
macAddress.Append(temp.Substring(x -, ) +"-");
}
x -=;
} return macAddress.ToString();
}
catch
{
return macAddress.ToString();
}
} [DllImport("Iphlpapi.dll")]
privatestaticexternint SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
[DllImport("Ws2_32.dll")]
privatestaticextern Int32 inet_addr(string ip);

C#中通过SendARP读取MAC地址的更多相关文章

  1. 几种C#程序读取MAC地址的方法

    原文:几种C#程序读取MAC地址的方法 以下是收集的几种C#程序读取MAC地址的方法,示例中是读取所有网卡的MAC地址,如果仅需要读取其中一个,稍作修改即可. 1 通过IPConfig命令读取MAC地 ...

  2. C# 几种读取MAC地址的方法

    以下是收集的几种C#程序读取MAC地址的方法,示例中是读取所有网卡的MAC地址,如果仅需要读取其中一个,稍作修改即可. 1 通过IPConfig命令读取MAC地址 ///<summary> ...

  3. 获得Unix/Linux系统中的IP、MAC地址等信息

    获得Unix/Linux系统中的IP.MAC地址等信息 中高级  |  2010-07-13 16:03  |  分类:①C语言. Unix/Linux. 网络编程 ②手册  |  4,471 次阅读 ...

  4. 使用 SendARP 获取 MAC 地址(使用SendARP API函数,很多相关文章)

    ARP 协议地址解析协议(ARP)是通过解析网路层地址来找寻数据链路层地址的一个在网络协议包中极其重要的网络传输协议.ARP 最初在 1982 年的 RFC 826 中提出并纳入互联网标准 STD 3 ...

  5. C#通过WMI读取MAC地址

    该方法依赖WMI的系统服务,该服务一般不会被关闭;但如果系统服务缺失或者出现问题,该方法无法取得MAC地址,需要重启Windows Management Instrumentation服务. publ ...

  6. c语言getipaddrtable获得ip地址与sendArp获得mac地址以及一些字节序问题记录

    https://docs.microsoft.com/zh-cn/windows/win32/api/iphlpapi/nf-iphlpapi-getipaddrtable msdn,有很多c的源码还 ...

  7. C#程序读取MAC地址的五种方法(转)

    public class GetMac { ///<summary> /// 根据截取ipconfig /all命令的输出流获取网卡Mac ///</summary> ///& ...

  8. 获取客户端Mac地址

    近期有个需求,需要获取客户端Mac地址作为白名单验证的依据.使用.net,B/S架构.先百度找了一些获取mac地址的方法, using System; using System.Collections ...

  9. (转)C#读取MAC的几种方法

    原文地址:http://www.cnblogs.com/diulela/archive/2012/04/07/2436111.html 1 通过IPConfig命令读取MAC地址 ///<sum ...

随机推荐

  1. STM32CubeMX自建MDK工程的基本步骤

    根据需要调节各总线频率 最下方选项,√去掉,不用实时更新库,选择自己库所在路径就好. 点击左侧, 选择"Code Generator", 选择.c 和 .h文件不分开 最后,点击& ...

  2. 安卓android eclipse运行提示no compatible targets were found

    在eclipse中开发安卓应用,运行项目时,右击项目名称---Run As---Android Application时, 系统提示"No compatible targets were f ...

  3. Spark学习之路 (二)Spark2.3 HA集群的分布式安装[转]

    下载Spark安装包 从官网下载 http://spark.apache.org/downloads.html 从微软的镜像站下载 http://mirrors.hust.edu.cn/apache/ ...

  4. react admin

    react admin 管理后台的快速创建方式

  5. Win10安装7 —— 系统的优化

    本文内容皆为作者原创,如需转载,请注明出处:https://www.cnblogs.com/xuexianqi/p/12371356.html 一:引言 在我们使用电脑的过程中,总是有一些窗口弹出来需 ...

  6. yum装包报错

    [root@iZ6wefn2kl6064uuaxuwetZ ~]# yum –y install  gcc  pcre-devel zlib-devel openssl-develLoaded plu ...

  7. 合唱队形【dp】

    链接:https://ac.nowcoder.com/acm/contest/1082/C来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言2621 ...

  8. window.location.herf传值问题

    各个值之间用&&&&&&连接 新版本的tomcat不支持其他字符,需要通过encodeURIComponent编码 变量名数字后不能直接加字母 such ...

  9. Mysql-从库只读设置

    主从设置中,如果从库在my.cnf中使用init_connect来限制只读权限的话,从库使用非超级用户(super权限)登陆数据时,无法进行任何操作,仅可维持主从复制. init_connect='S ...

  10. 获取table中CheckBox选中行的id

    方式一 var selectList=''; jQuery(".table tbody input[type=checkbox]:checked").map(function () ...