Question

Can anyone help me out trying to find a WMI method for retrieving hardware addresses and IRQs?

The classes I've looked at so far seem a bit empty for telling you what device is actually using the resource - but it must be possible if it's available under Windows' 'System Information' tool.

Ultimately I want to create an address map and an IRQ map in my C# application.

I've briefly looked at the following classes:

  • Win32_DeviceMemoryAddress
  • Win32_IRQResource

and I just this second saw another, but I haven't really looked into it:

  • Win32_AllocatedResource

Maybe pairing it with Win32_PnPEntity?

Était-ce utile?

La solution

To get that info you must use the ASSOCIATORS OF WQL sentence to create a link between the Win32_DeviceMemoryAddress -> Win32_PnPEntity -> Win32_IRQResource classes.

Check this sample app

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();
        }
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top