当前位置:网站首页>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。。就可以了。。
边栏推荐
- 【场景化解决方案】ERP系统与钉钉实现数据互通
- [MySQL]mysql: Solve the problem of [Err] 1093 - You can't specify target table 'table name' for update in FROM clause
- Max Flow P
- ctfshow-web入门 文件上传篇部分题解
- 【CNN】2022 ECCV Oral 自反馈学习的mixup训练框架AutoMix
- QT program generates independent exe program (pit-avoiding version)
- mysql-5.5.40的完全卸载
- leetcode 36. 有效的数独(模拟题)
- 内存中的swap机制
- Go语言技巧之正确高效使用slice(听课笔记总结--简单易懂)
猜你喜欢
随机推荐
makefile - 学习小结
uniapp编译到小程序后丢失static文件夹问题
Account and Permission Management
【CNN】2022 ECCV Oral 自反馈学习的mixup训练框架AutoMix
Shell programming loop statement and function
How does STM32 know the usage of FLASH
QT程序生成独立exe程序(避坑版)
【场景化解决方案】搭建数据桥梁,Dslink打通泛微系统连接流
Dark Horse 2022 latest redis course notes and knowledge points (for interview)
leetcode 36. 有效的数独(模拟题)
Literature retrieval operation code
【KD】2022 KDD Compressing Deep Graph Neural Networks via Adversarial Knowledge Distillation
【Harmony OS】【ARK UI】公共事件模块
elder blind date
canvas 文字垂直居中
QT设置exe可执行文件的图标
长辈相亲
leetcode 34. 在排序数组中查找元素的第一个和最后一个位置(二分经典题)
Arduino+2片74hc595 驱动8x8(共阳)点阵(1008BS)
UE4 RTS 框选功能实现