谁能帮助我找到用于检索硬件地址和IRQ的WMI方法?

到目前为止,我看过的类似乎有些空白,无法告诉您实际使用资源的设备是什么,但是如果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();
        }
    }
}

09-19 08:40