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));
}