当前位置:网站首页>C#获取网卡地址
C#获取网卡地址
2022-08-09 08:56:00 【l8487】
using System;
using System.Management;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo["IPEnabled"] == true)
Label1.Text = mo["MacAddress"].ToString();
}
}
}
好简单的代码啊。但是需要using System.Management;
引入方法是菜单“网站”-“添加引用”-net中的System.Management。。就可以了。。
边栏推荐
猜你喜欢

leetcode 35. 搜索插入位置(二分法+找性质也很关键)

ctfshow-web入门 文件上传篇部分题解

BUUCTF MISC Writing Notes (1)

XCTF College War "Epidemic" Network Security Sharing Competition Misc wp

leetcode 32. 最长有效括号 (困难)

UE4 RTS frame selection function implementation

UE4 RTS 框选功能实现

VoLTE基础自学系列 | IMS的业务触发机制

BUUCTF MISC刷题笔记(一)

Three handshakes, four waves
随机推荐
【LeetCode每日一题】——225.用队列实现栈
RESTful
Introduction to Network Layer Protocols
Where does detection go forward?
elder blind date
消息中间件(MQ)前置知识介绍(必看)
leetcode 36. 有效的数独(模拟题)
GBJ610-ASEMI超薄整流扁桥GBJ610
【场景化解决方案】OA审批与金智CRM数据同步
Routing configuration forwarding and experiment
管理方向发展
第五届蓝帽杯初赛 misc 赛后复现
makefile的foreach、filter、filter-out函数
【愚公系列】2022年08月 Go教学课程 033-结构体方法重写、方法值、方法表达式
【CNN】白话迁移学习中域适应
The difference between big-endian and little-endian storage is easy to understand at a glance
leetcode 37. 解数独 (困难)
6000 字+,帮你搞懂互联网架构演变历程!
腾讯云服务器修改为root登录安装宝塔面板
解决iframe跳转时父页面仍然存在的问题