1

Here is my code, I have copied from one of your question and the code is :

class Program
{
    static void Main(string[] args)
    {
        try
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI","SELECT * FROM MSWmi_PnPInstanceNames");


            foreach (ManagementObject queryObj in searcher.Get())
            {
                Console.WriteLine("-----------------------------------");
                //Console.WriteLine("MSWmi_PnPInstanceNames instance");
                //Console.WriteLine("-----------------------------------");
                Console.WriteLine("InstanceName: {0}", queryObj["InstanceName"]);

            }

            Console.Read();

        }
        catch (ManagementException e)
        {
            MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
        }
    }

}

Now, my question is : what is the element of queryObj array ?

Maruf Hossain
  • 101
  • 1
  • 3
  • 17

1 Answers1

1

ManagementObjectSearcher.Get() method return type is ManagementObjectCollection.

The objects in this collection are of ManagementBaseObject-derived types, including ManagementObject and ManagementClass.

From ManagementObjectSearcher.Get() method;

Invokes the specified WMI query and returns the resulting collection.

InstanceName is proopertyName for instance of ManagementObject which returns from ManagementObjectSearcher.Get method.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364