C#中通过SendARP读取MAC地址
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地址的更多相关文章
- 几种C#程序读取MAC地址的方法
原文:几种C#程序读取MAC地址的方法 以下是收集的几种C#程序读取MAC地址的方法,示例中是读取所有网卡的MAC地址,如果仅需要读取其中一个,稍作修改即可. 1 通过IPConfig命令读取MAC地 ...
- C# 几种读取MAC地址的方法
以下是收集的几种C#程序读取MAC地址的方法,示例中是读取所有网卡的MAC地址,如果仅需要读取其中一个,稍作修改即可. 1 通过IPConfig命令读取MAC地址 ///<summary> ...
- 获得Unix/Linux系统中的IP、MAC地址等信息
获得Unix/Linux系统中的IP.MAC地址等信息 中高级 | 2010-07-13 16:03 | 分类:①C语言. Unix/Linux. 网络编程 ②手册 | 4,471 次阅读 ...
- 使用 SendARP 获取 MAC 地址(使用SendARP API函数,很多相关文章)
ARP 协议地址解析协议(ARP)是通过解析网路层地址来找寻数据链路层地址的一个在网络协议包中极其重要的网络传输协议.ARP 最初在 1982 年的 RFC 826 中提出并纳入互联网标准 STD 3 ...
- C#通过WMI读取MAC地址
该方法依赖WMI的系统服务,该服务一般不会被关闭;但如果系统服务缺失或者出现问题,该方法无法取得MAC地址,需要重启Windows Management Instrumentation服务. publ ...
- c语言getipaddrtable获得ip地址与sendArp获得mac地址以及一些字节序问题记录
https://docs.microsoft.com/zh-cn/windows/win32/api/iphlpapi/nf-iphlpapi-getipaddrtable msdn,有很多c的源码还 ...
- C#程序读取MAC地址的五种方法(转)
public class GetMac { ///<summary> /// 根据截取ipconfig /all命令的输出流获取网卡Mac ///</summary> ///& ...
- 获取客户端Mac地址
近期有个需求,需要获取客户端Mac地址作为白名单验证的依据.使用.net,B/S架构.先百度找了一些获取mac地址的方法, using System; using System.Collections ...
- (转)C#读取MAC的几种方法
原文地址:http://www.cnblogs.com/diulela/archive/2012/04/07/2436111.html 1 通过IPConfig命令读取MAC地址 ///<sum ...
随机推荐
- 解决ios手机中input输入框光标过长的问题
修改前css部分代码: .receiving-info .receiving-info-list input { display: inline-block; width: 70%; font-siz ...
- win10专业工作站版密钥|win10专业工作站版key|win10专业工作站版激活码
一.windows10专业工作站零售版密钥 永久激活 Win 10 ProfessionalWorkstation Retail [Key]:DXG7C-N36C4-C4HTG-X4T3X-2YV77 ...
- Docker最全教程——从理论到实战(十六)
前言 与其他语言相比,Go非常值得推荐和学习,真香!为什么?主要是可以直接编译成机器代码(性能优越,体积非常小,可达10来M,见实践教程图片)而且设计良好,上手门槛低.本篇主要侧重于讲解了Go语言的优 ...
- java学习笔记之IO编程—File文件操作类
1. File类说明 在Java语言里面提供有对于文件操作系统操作的支持,而这个支持就在java.io.File类中进行了定义,也就是说在整个java.io包里面,File类是唯一一个与文件本身操作( ...
- SendMessage模拟按键所需的虚拟键码
Virtual-Key Codes The following table shows the symbolic constant names, hexadecimal values, and mou ...
- JS使用知识点理解
var keyValue = $.request("keyValue"); $(function () { ////修改页面select下拉选框js $("#BloodB ...
- macOS 下安装tomcat
The Servlet 4.0 specification is out and Tomcat 9.0.x does support it. Time to dive into Tomcat 9. [ ...
- <if test="type == '0' ">没有进去这个判断的问题
在MyBatis的mapp文件中的if判断中是这样写的 <if test="type == '0' "> and so1.id = #{unitcode} </i ...
- 3ds Max File Format (Part 1: The outer file format; OLE2)
The 3ds Max file format, not too much documentation to be found about it. There are some hints here ...
- Codeforces Round #600 (Div. 2) C - Sweets Eating
#include<iostream> #include<algorithm> #include<cstring> using namespace std ; typ ...