How to

enumerate system drivers

Published: 12. February 2012 | Updated: 12. February 2012
License: Microsoft Public License (MS-PL)
Categories: Windows » Hardware
Tags: C# Hardware Windows WMI
Was this snippet helpful for you? YESYES / NONO
Get Analyzant!

Check your entire website from code to content in minutes with Analyzant, the free analysis suite.

Free download at

Import namespaces

using System;
using System.Collections.Generic;
using System.Management; // requires adding System.Management reference to project


ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_SystemDriver");
ManagementObjectCollection collection = searcher.Get();

var items = new List<Win32_SystemDriver>();
foreach (ManagementObject obj in collection)
    var item = new Win32_SystemDriver();
    item.AcceptPause = (bool?)obj["AcceptPause"];
    item.AcceptStop = (bool?)obj["AcceptStop"];
    item.Caption = (string)obj["Caption"];
    item.CreationClassName = (string)obj["CreationClassName"];
    item.Description = (string)obj["Description"];
    item.DesktopInteract = (bool?)obj["DesktopInteract"];
    item.DisplayName = (string)obj["DisplayName"];
    item.ErrorControl = (string)obj["ErrorControl"];
    item.ExitCode = (uint?)obj["ExitCode"];
    item.InstallDate = (DateTime?)obj["InstallDate"];
    item.Name = (string)obj["Name"];
    item.PathName = (string)obj["PathName"];
    item.ServiceSpecificExitCode = (uint?)obj["ServiceSpecificExitCode"];
    item.ServiceType = (string)obj["ServiceType"];
    item.Started = (bool?)obj["Started"];
    item.StartMode = (string)obj["StartMode"];
    item.StartName = (string)obj["StartName"];
    item.State = (string)obj["State"];
    item.Status = (string)obj["Status"];
    item.SystemCreationClassName = (string)obj["SystemCreationClassName"];
    item.SystemName = (string)obj["SystemName"];
    item.TagId = (uint?)obj["TagId"];



public class Win32_SystemDriver
    public bool? AcceptPause;
    public bool? AcceptStop;
    public string Caption;
    public string CreationClassName;
    public string Description;
    public bool? DesktopInteract;
    public string DisplayName;
    public string ErrorControl;
    public uint? ExitCode;
    public DateTime? InstallDate;
    public string Name;
    public string PathName;
    public uint? ServiceSpecificExitCode;
    public string ServiceType;
    public bool? Started;
    public string StartMode;
    public string StartName;
    public string State;
    public string Status;
    public string SystemCreationClassName;
    public string SystemName;
    public uint? TagId;
Send us feedback about this snippet »

Related Snippets: