WMI硬件地址和IRQ

时间:2012-03-20 13:38:04

标签: c# wmi memory-address irq

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

到目前为止我看过的课程似乎有点空洞,因为它告诉你什么设备实际上正在使用资源 - 但如果它在Windows“系统信息”工具下可用,它必须是可能的。

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

我简要介绍了以下几个类:

  • Win32_DeviceMemoryAddress
  • Win32_IRQResource

而我刚刚看到另一个,但我还没有真正研究过它:

  • Win32_AllocatedResource

可能将它与Win32_PnPEntity配对?

1 个答案:

答案 0 :(得分:4)

要获取该信息,您必须使用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();
        }
    }
}