Get the currently "Active" driver for a device in C++ - c++

I have used SetupAPI to enumerate all the drivers, build a list of its properties etc etc. But what i want is to enumerate only the "Active" drivers for any device.
Eg. For a Intel HD 5500, There are a couple of drivers installed in the System with different versions like
20.19.15.4531
20.19.15.4454
But the version shown in DeviceManager is 20.19.15.4531. I need to get only this version.
When I use SetupAPI, I Get both the drivers. I've tried the solution listed at This Post but I can confirm that the solution does not work for me.
SetupDiGetSelectedDriver() also does not work. i.e. It works only when we are installing a driver to the store using SetupAPI functions.
Any Help will be really appreciated.
Note : There is no problem in finding and Enumerating the drivers. I use SetupDiBuildDriverInfoList() and SetupDiEnumDrvInfo(), and they work as expected.

I Finally ended up building a list of current drivers using WMI in c++. Couldn't find a way out!

Related

Find out the active graphics driver using SetupAPI

I try to find out the version of the currently active graphics driver on Windows using C++ and SetupAPI. The solution roughly looks like
Call SetupDiGetClassDevs for GUID_DEVCLASS_DISPLAY.
Call SetupDiBuildDriverInfoList for the result set.
Call SetupDiEnumDriverInfo for the device set with SPDIT_COMPATDRIVER, which gives me all known drivers compatible with the GPU.
The result includes the fallback driver from Microsoft, which I can easily exclute, but it also includes all driver versions (from NVIDIA) that have been installed on the system.
The question is: How do I find out which of the drivers is actually running?
I know from the SP_DEVINFO_DATA returned in step 1 how the driver service is called and I also get some kind of registry key, but I do not see how I could relate this to the SP_DRVINFO_DATA. I also know that NVAPI provides driver management capabilities, but I would prefer a solution that works with GPUs of all kinds of vendors.
Just FYI, you can also query the SPDRP_DRIVER via SetupDiGetDeviceRegistryProperty and then lookup that registry value under Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\. That key contains all the driver info. Here is some sample code from WebKit that actually retrieves GPU info this way.
I found the solution in the meantime at Why does SetupDiEnumDriverInfo give two version numbers for my driver: You need to update the install parameters of the device information set with the DI_FLAGSEX_INSTALLEDDRIVER flag before step 3.

Microphone list (input device list) in Windows

I am wondering how can I ask Windows and retrieve a list over current input devices?
Language is C++.
The goal is to select from the list in a program I am making.
Tried searching a bit, but found nothing..
Please help :)
Thank you.
For the sake of future reference, it might be worth mentioning the RtAudio library, which is also written in C++ and is multiplatform on Windows, OS-X and Linux.
On Windows you can compile it either using the ASIO SDK (in case your devices have an ASIO driver), DirectSound (part of DirectX, old and deprecated, but still working), or WASAPI (introduced in Windows Vista).
With RtAudio you can manage devices very easily with class method calls such as:
RtAudio::startStream();
RtAudio::stopStream();
RtAudio::getDeviceCount();
RtAudio::getDefaultInputDevice();
RtAudio::getDeviceInfo(uint deviceID);
You can also manage output devices in the same fashion.
This can be done through the WaveIn Windows API. Since there is already a post with code to enumarate and retrieve the names of input devices here I won't make a new one.

Accessing device via existing device driver

I'm looking to write an application that will allow me to control music, etc with a remote control. The infrared receiver I have is built into my MacBook Pro which is running Windows.
What I want to know is how can I go about this? Most of the information I can find online is specific to writing Windows device drivers and I'm having trouble finding out how to use drivers that already exist for a device.
Is it absolutely necessary for me to write my own drivers or is there a way to use the drivers provided by Apple?
On Windows you communicate with a driver by first opening it using CreateFile and subsequently sending commands to it using DeviceIoControl. You need documentation for the driver's API though to understand what functionality is available through which control codes and what parameters they expect. Digging up that information is probably the hard part.

Can EnumDisplayDevices detect a device if it's drivers are not installed?

I need to deploy a hard drive image to a customer which on the first boot detects the graphics card type and installs the appropriate drivers. So what this means in terms of code is that I need to detect the deviceid of the graphics card in C++ without using GPU specific libraries like NvAPI or AMD SDK.
I know that EnumDisplayDevices can retrieve deviceids, so all I need to know is whether this is possible with EnumDisplayDevices, or whether the GPUs drivers must be installed before EnumDisplayDevices can detect it. How the function actually goes about obtaining this information isn't mentioned in the MSDN article.
Thanks,
Bill.
For my purposes I needed to know the name and model of the graphics card, and it turns out EnumDisplayDevices can't retrieve this information until the drivers are installed.

How to get started with Drivers Programming under windows

I want to start learning drivers programming under windows .
I never programed drivers , and i am looking for information how to get started .
Any tutorials ,links ,book recommendations , and what development tool kit i should start with ? (WDF will be good one ?)
I really want to program following clock link text
Thanks for your help .
I would start by downloading the windows driver kit (WDK).
Afterwards, you decide which kind of driver you want. FileSystem driver? (probably not), RS-232 driver? usb driver? They all follow different rules and quirks.
The WDK comes with examples drivers for most kinds of drivers and should get you on track fast.
To interact with USB hardware you would be best served by looking at WinUSB or the Usermode Driver Framework. Usermode drivers are orders of magnitude easier, being able to use a C++/COM(kind of) framework and a normal debugging environment.
Writing kernelmode drivers should be reserved for stuff like video card, disk, and other latency/throughput sensitive drivers.
An even easier method would be to use libusb-win32 which is a C library that makes talking to a USB endpoint almost as easy as writing data to a file.
Must see resource for windows driver development, of course as addition to the WDK mentioned by Eric.