How to enumerate all device drivers in the system

24 02 2009




Does anybody know how to enumerate all device drivers in our system.




PSAPI itself giving differnt APIs to do this. EnumDeviceDrivers and GetDeviceDriverBaseName are the APIs used for this.




void DisplayDeviceDrivers()
   LPVOID   drivers[ARRAY_SIZE];
   DWORD    cbNeeded;
   int      cDrivers, i;
   if( EnumDeviceDrivers(drivers, sizeof(drivers), &cbNeeded) &&
      cbNeeded < sizeof(drivers))
      TCHAR szDriver[ARRAY_SIZE];
      cDrivers = cbNeeded/sizeof(drivers[0]);
      AfxMessageBox("Total Device Drivers count : %ul", cDrivers);
      for (i=0; i < cDrivers; i++ )
         GetDeviceDriverBaseName( drivers[i], szDriver, sizeof(szDriver)/sizeof(szDriver[0]) );
         CString str;
         str.Format("%d: %s", i+1, szDriver);
      AfxMessageBox("EnumDeviceDrivers failed.");




Don’t forget to include Psapi.lib to library modules.



2 responses

7 07 2014

hello master, im new on programming, and ur guides perfect sharing, if u got free time can u bind that “device”,”listing task” and “ram” functions for vs2010? i cannot compile cstring gives error, thx

7 07 2014

i fixed it via project settings->general->character set->”Use Multi-Byte Character Set” thank you for toturial.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: