资源简介
C#修改网卡MAC地址的源码,可以随机生成mac地址,亲测可用,测试环境,windows 7 ,VS2013,稍作修改可以做成一键换地址。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Management;
using Microsoft.Win32;
using System.Net.NetworkInformation;
using System.Text.Regularexpressions;
namespace MACAddressTool
{
public partial class Form1 : Form
{
public class Adapter
{
public Managementobject adapter;
public string adaptername;
public string customname;
public int devnum;
public Adapter(Managementobject a string aname string cname int n)
{
this.adapter = a;
this.adaptername = aname;
this.customname = cname;
this.devnum = n;
}
public Adapter(NetworkInterface i) : this(i.Description) { }
public Adapter(string aname)
{
this.adaptername = aname;
var searcher = new ManagementobjectSearcher(“select * from win32_networkadapter where Name=‘“ + adaptername + “‘“);
var found = searcher.Get();
this.adapter = found.Castject>().FirstOrDefault();
// Extract adapter number; this should correspond to the keys under
// HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}
try
{
var match = Regex.Match(adapter.Path.RelativePath “\\\“(\\d+)\\\“$“);
this.devnum = int.Parse(match.Groups[1].Value);
}
catch
{
return;
}
// Find the name the user gave to it in “Network Adapters“
this.customname = NetworkInterface.GetAllNetworkInterfaces().Where(
i => i.Description == adaptername
).Select(
i => “ (“ + i.Name + “)“
).FirstOrDefault();
}
public NetworkInterface ManagedAdapter
{
get
{
return NetworkInterface.GetAllNetworkInterfaces().Where(
nic => nic.Description == this.adaptername
).FirstOrDefault();
}
}
public string Mac
{
get
{
try
{
return BitConverter.ToString(this.ManagedAdapter.GetPhysicalAddress().GetAddressBytes()).Replace(“-“ ““).ToUpper();
}
catch { return null; }
}
}
public string RegistryKey
{
get
{
return String.Format(@“SYSTEM\ControlSet0
相关资源
- JS、ASP、ASP.NET获取MAC地址、机器名、
- 一款专业的双网卡自动切换软件卓高
- 乳腺癌威斯康星预后数据集
- WMI 获取计算机信息cpu 硬盘 网卡 网速
-
AForge.NET_fr
amework-2.1.3 一个C#下面的图 - FindNetDevices
- C# 利用网卡序列号设计软件注册程序
- verbit修改版,将codec生成verbs.txt文件不
- 获取本地硬盘 cpu 内存 网卡上传
- 获取唯一机器码,读取CPU_ID,硬盘序
- C# 获取电脑的IP,网关,MAC,计算机名
- c#实现取局域网内根据MAC地址获取IP地
- C# 获取电脑上传速度(网卡)
- 获取局域网IP和MAC地址 .txt
- POS machine Csharp_inventory_management_syste
- C# 获取本机mac地址(网卡)
- C#抓包,SnifferHttp使用网卡获取Http请求
- C#获取局域网内所有计算机的IP地址和
- C#HALCON开发的完整视觉检测案例Machi
- C#获取本机MAC地址本机联网网卡
- 源码:获取本地网络信息(ip/mac/计算
评论
共有 条评论