c# - 使用winmgmts读取我电脑的mac地址
问题描述
我有以下代码
object objectValue1 = RuntimeHelpers.GetObjectValue(NewLateBinding.LateGet(RuntimeHelpers.GetObjectValue(Interaction.GetObject("winmgmts:\\\\.\\root\\cimv2", (string) null)), (Type) null, "ExecQuery", new object[1]
{
(object) "Select * from WIN32_NetworkAdapterConfiguration"
}, (string[]) null, (Type[]) null, (bool[]) null));
try
{
foreach (object obj in (IEnumerable) objectValue1)
{
object objectValue2 = RuntimeHelpers.GetObjectValue(obj);
string Left;
try
{
Left = Conversions.ToString(NewLateBinding.LateGet(objectValue2, (Type) null, "MACAddress", new object[0], (string[]) null, (Type[]) null, (bool[]) null));
}
我试图读出我的mac地址,但问题是我有时有3倍相同的mac地址,有时我的ras适配器的mac地址会改变。你能帮助我吗?
解决方案
推荐阅读
- javascript - Magnific-popup enqueue 样式表未在 wordpress 中正确加载
- regex - ocaml Str.full_split 不返回原始字符串而不是预期的子字符串
- javascript - 有没有办法改变 JavaScript 中的 ::after 样式?
- r - 如何将颜色图例添加到具有不同几何图层的 ggplot
- git - GitHub 扩展报告我可以从浏览器访问的相同 repo URL 的 404 错误
- git - 致命:无法锁定 ref 'HEAD':无法创建 'G:/folder/.git/HEAD.lock':文件存在
- javascript - 一个会话的返回路径
- assembly - 为什么即使包含 JUMPDEST 也无法跳入指令?
- android - 没有firebase的iOS和Android的Flutter推送通知?
- r - R:从数据框列中获取 JSON 字符串的向量(逐行)