当前位置:网站首页>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。。就可以了。。
边栏推荐
猜你喜欢

Redis redis 】 【 the expiration of listening

法院3D导航系统-轻松实现室内实时定位导航

没有对象的可以进来看看, 这里有对象介绍

Dark Horse 2022 latest redis course notes and knowledge points (for interview)

ASEMI整流桥GBJ810参数,GBJ810封装,GBJ810重量

Routing configuration forwarding and experiment
![[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause](/img/76/8e6a3a1c5fdc9bffc0c7c9187a027c.png)
[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause

Kibana:为地图应用选择不同的语言 - Elastic Stack 8.3

canvas 文字垂直居中

leetcode 36. 有效的数独(模拟题)
随机推荐
探索APP性能优化之稳定性优化(解决方案)
医院智能3D蓝牙导航导诊系统
BUUCTF MISC刷题笔记(一)
Conversion between number systems
QT程序生成独立exe程序(避坑版)
QT program generates independent exe program (pit-avoiding version)
nyoj58 最少步数(DFS)
【场景化解决方案】构建设备通讯录,制造业设备上钉实现设备高效管理
js实现看板全屏功能
Three handshakes, four waves
+ 6000 words, help you understand the Internet architecture evolution.
[MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause
Calendar类和Date类转换时区 && 部分时区城市列表
【LeetCode每日一题】——225.用队列实现栈
大学四年不努力,出社会后浑浑噩噩深感无力,辞去工作,从头开始
requests之数据解析Xpath介绍
Kibana:为地图应用选择不同的语言 - Elastic Stack 8.3
【GNN终身学习】2022 CVPR 终身图学习
ctf misc 图片题知识点
UE4 RTS 框选功能实现