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

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.

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.

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.

How to get GPU information in C++ before the drivers are installed

We have a piece of software which can run on several different graphics cards, both ATI and NVIDIA. I need to be able to determine either the device id or the model name of the graphics card before its drivers are installed, so that I can create a hard drive image which can be booted up with any of the graphics cards we support, have it detect the graphics card on first boot, install the drivers then restart. Target platform is WinXP.
I tried using WMI but that can only retrieve information about the display adapter, which doesn't include the device id, and before the drivers are installed the display adapter will just has generic data like "Video Controller (VGA)" for the name and so on.
EnumDisplayDevices cannot detect the device until after its drivers are installed.
This must be possible, as when the new hardware wizard opens it knows the name of the graphics card, but I just can't find a way of doing it.
Any ideas?
EDIT - Here's the query
ExecQuery(bstr_t("WQL"),bstr_t("SELECT * FROM Win32_PnPEntity WHERE DeviceID LIKE 'PCI\\VEN'"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
For future reference for other users I'll add my own answer.
Contrary to what I said in my post, WMI can in fact detect uninstalled devices, by querying for Win32_PNPEntity you can get their device ids.

How to determine in C++ the video driver version?

I've got a graphics application that appears to have funky behavior with certain combinations of video cards and drivers. I would like to capture in the application the version number of the video card driver to help with debugging. Is there an easy way to do this?
It depends on the operating system. In Windows, you use Windows Management Instrumentation (WMI). There is an example here that gets the name of the operating system. To get the name of the video driver(s), replace "Win32_OperatingSystem" with "Win32_VideoController" in the example.

How do I use C++ to acquire image from frame grabber?

I would like to know how is it possible to use a free C++ program to acquire image from a matrix vision frame grabber. Thanks.
See http://www.matrix-vision.com/support/hardwareinfo.php?lang=en
Check the documentation of your frame grabber card. Look for "SDK" (software development kit). Maybe your operating system has its own interface which you can use if the "driver" has been installed. I would guess you have to do both things: Install all drivers and use some special library as part of the SDK that is provided with this product.
The SDK (hopefully a dll with some exported functions for your help) usually comes by installing the grabber's drivers.Since it is a graphic card my guess would be that it would be found among the media devices which you can retrieve.
The SDK is stand alone and therefore can be used by your code in c++