How to enumerate device drivers?
One of my friend said that there’s no documented API to enumerate the device drivers loaded in the system. But I could exactly remember I had done it 2-3 years back when I was just joined in the company. But I could not exactly rememeber which was that API. Still the smell of those good old days where I was fresher so that I was fascinated about learning the new stuffs and do experiments. Now the busy schedules and responsibility and also laziness not allowing me to be like that old
. At that time I was really interested in writing a process viewer. A small wish of a fresher and I could really do that. Just started with enumerating process but it opened many doors infront of me. The cool APIs of PSAPI library and alot more to experiment and I enumerated most of the things in the system whcih can be acheived through direct documented APIs and put in my process explorer and also learnt about the stuffs of drawing under windows as part of creating my GUI :). Unfortunately I missed those code anyway I will try to repost it once if I get those from the archived CDs. hmmm still the smell of good old days!!
Here’s the sample snippet snippet. It’s still there in MSDN
#include <windows.h>
#include <psapi.h>
#include <tchar.h>
#include <stdio.h>
#define ARRAY_SIZE 1024
void main()
{
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]);
_tprintf(TEXT(“There are %d drivers:\n”), cDrivers);
for (i=0; i < cDrivers; i++ )
{
if(GetDeviceDriverBaseName(drivers[i], szDriver,
sizeof(szDriver)/sizeof(szDriver[0])))
_tprintf(TEXT(“%d: %s\n”), i+1, szDriver);
}
}
else
_tprintf(TEXT(
“EnumDeviceDrivers failed; array size needed is %d\n”),
cbNeeded/sizeof(LPVOID));
}
about 2 years ago
I’m having some issues with this API, but only on this platform and only in a 32-bit application. See my other posts:
http://www.codeguru.com/forum/showthread.php?t=424997
http://groups.google.ro/group/microsoft.public.development.device.drivers/browse_frm/thread/58f3c68095a2e55a/35138a526b1438ad?lnk=st&q=EnumDeviceDrivers+x64&rnum=1&hl=ro#35138a526b1438ad
Can you please check this if it’s working on XP 64-bit version, in a 32-bit application ?
about 1 year ago
Er29DU sdbgh83kdf0umfn3fdhzp
about 1 year ago
i need the complete file name for the drivers. there is another psapi function GetDeviceDriverFileNameW which should return file names with full path but it isn’t always so. And is there a method to link the drivers to the devices installed in the system?(like in Device Manager when pressing driver details button)