How to enumerate all device drivers in the system

24 02 2009

description5

 

 

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

howcanidoit6

 

 

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

mycodesnippet5

 

 

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(str);
        
      }
   }
   else
      AfxMessageBox("EnumDeviceDrivers failed.");
}

mynote5

 

 

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

Advertisements

Actions

Information

2 responses

7 07 2014
Newbie

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
Newbie

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:

WordPress.com Logo

You are commenting using your WordPress.com 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: