WMI硬件地址和IRQ

本文关键字:IRQ 硬件地址 WMI | 更新日期: 2023-09-27 18:28:35

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

到目前为止,我所查看的类似乎有点空,无法告诉您实际使用资源的设备是什么——但如果它在Windows的"系统信息"工具下可用,则这一定是可能的。

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

我简要介绍了以下课程:

  • Win32_DeviceMemoryAddress
  • Win32_IRQ资源

就在这一秒,我看到了另一个,但我还没有真正研究过:

  • Win32_AllocatedResource

也许将其与Win32_PnPEntity配对?

WMI硬件地址和IRQ

要获得该信息,必须使用ASSOCIATORS OF WQL语句在Win32_DeviceMemoryAddress->Win32_PnPEntity->Win32_IRQ资源类别。

检查此示例应用

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();
        }
    }
}