1

任何人都可以帮助我找到一种 WMI 方法来检索硬件地址和 IRQ 吗?

到目前为止,我查看的类似乎有点空洞,无法告诉您实际使用资源的设备 - 但如果它在 Windows 的“系统信息”工具下可用,则它必须是可能的。

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

我简要地查看了以下课程:

  • Win32_DeviceMemoryAddress
  • Win32_IRQResource

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

  • Win32_AllocatedResource

也许将它与 Win32_PnPEntity 配对?

4

1 回答 1

4

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

检查此示例应用程序

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();
        }
    }
}
于 2012-03-21T12:24:31.297 回答