I'm having a really hard time figuring out how to do this. Basically, all I want to do is read all the devices that are attached to the machine and also read the driver manufacturer and version of the device driver. This is the information you can get in the device manager,but I want to do it programattically.
I've done a lot of searching and reading, and can't find anything that helps me do this. There is this WMI stuff that should work, but I can't find any examples that work. I've read and read about WMI, but still can't figure it out.
Are there any tutorials out there that might explain WMI better than the Microsoft site? I need this to be down be to the crayola level.
Please have a look at the following article
Get Your Hardware Information Using C#
Retrieving Information From Windows Management Instrumentation
EDIT:
I believe that you are looking for the following Win32_PnPSignedDriver class
public class Program
{
public static void Main()
{
ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("Select * from Win32_PnPSignedDriver");
ManagementObjectCollection objCollection = objSearcher.Get();
foreach (ManagementObject obj in objCollection)
{
string info = String.Format("Device='{0}',Manufacturer='{1}',DriverVersion='{2}' ", obj["DeviceName"], obj["Manufacturer"], obj["DriverVersion"]);
Console.Out.WriteLine(info);
}
Console.Write("\n\nAny key...");
Console.ReadKey();
}
}
Aslo, if you are going to work a lot on WMI you might as well use this tool, to avoid creating test applications.
If you are looking for a specific kind of device information (suppose only Bluetooth) from your machine - then
"ManagementObjectSearcher" in c# is good enough. You just need to includeusing System.Management;
put a condition search with it as following
ManagementObjectSearcher mos =
new ManagementObjectSearcher(@"\root\cimv2", @"Select * From Win32_PnPEntity WHERE ClassGuid = '"+deviceGuid+"'");
here "deviceGuid" is the device class type(a guid value [same for all PCs]).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With