I used SetupDiGetClassDevs()
, SetupDiEnumDeviceInfo()
and SetupDiGetDeviceRegistryProperty()
to enumerate my USB device and check whether my device is available or not.
How can I check whether my proper driver is installed for my device or not?
Is there any APIs available to check this?
You can get the driver information for the device and then check against that, if your driver is installed and up-to-data.
Here is a bit of C++ code which might help you:
bool fetchDriverDescription( const std::wstring& driverRegistryLocation, tDriverDescription& desc )
{
bool rval = false;
std::wstring regFolder = L"SYSTEM\\CurrentControlSet\\Control\\Class\\";
regFolder += driverRegistryLocation;
win32::registry::reg_key hKey =
win32::registry::reg_key::open( HKEY_LOCAL_MACHINE, regFolder, KEY_READ );
if( hKey )
{
if( win32::registry::read( hKey, L"ProviderName", desc.DriverProviderName, false ) != ERROR_SUCCESS )
return false;
desc.InstalledDriverRegFolder = regFolder;
std::wstring val;
if( win32::registry::read( hKey, L"DriverVersion", val, false ) == ERROR_SUCCESS )
desc.Version = val;
rval = true;
}
return rval;
}
std::wstring driverRegLocation;
if( fetchStringFromDiGetDevice( hDevInfo, DeviceInfo, SPDRP_DRIVER, driverRegLocation ) )
{
bSuccessful = fetchDriverDescription( driverRegLocation, dev.DriverDesc );
}