gpt4 book ai didi

c# - WMI 硬件地址和 IRQ

转载 作者:太空宇宙 更新时间:2023-11-03 22:01:55 24 4
gpt4 key购买 nike

谁能帮我找到一个 WMI 方法来检索硬件地址和 IRQ?

到目前为止,我看过的类在告诉您实际使用该资源的设备方面似乎有点空洞 - 但如果它在 Windows 的“系统信息”工具下可用,那肯定是可能的。

最终,我想在我的 C# 应用程序中创建一个地址映射和一个 IRQ 映射。

我简要地查看了以下类:

  • Win32_DeviceMemoryAddress
  • Win32_IRQResource

我刚刚看到另一个,但我还没有真正调查过:

  • Win32_AllocatedResource

也许将其与 Win32_PnPEntity 配对?

最佳答案

要获取该信息,您必须使用 ASSOCIATORS OF WQL 语句之间创建链接 Win32_DeviceMemoryAddress -> Win32_PnPEntity -> Win32_IRQResource类。

检查这个示例应用

using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Text;

namespace WMIIRQ
{
class Program
{
static void Main(string[] args)
{
foreach(ManagementObject Memory in new ManagementObjectSearcher(
"select * from Win32_DeviceMemoryAddress").Get())
{

Console.WriteLine("Address=" + Memory["Name"]);
// associate Memory addresses with Pnp Devices
foreach(ManagementObject Pnp in new ManagementObjectSearcher(
"ASSOCIATORS OF {Win32_DeviceMemoryAddress.StartingAddress='" + Memory["StartingAddress"] + "'} WHERE RESULTCLASS = Win32_PnPEntity").Get())
{
Console.WriteLine(" Pnp Device =" + Pnp["Caption"]);

// associate Pnp Devices with IRQ
foreach(ManagementObject IRQ in new ManagementObjectSearcher(
"ASSOCIATORS OF {Win32_PnPEntity.DeviceID='" + Pnp["PNPDeviceID"] + "'} WHERE RESULTCLASS = Win32_IRQResource").Get())
{
Console.WriteLine(" IRQ=" + IRQ["Name"]);
}
}

}
Console.ReadLine();
}
}
}

关于c# - WMI 硬件地址和 IRQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9787892/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com