I have an application that is looking at existing drivers. It creates an
HDEVINFO with all present devices using SetupDiGetClassDevs, walks through
them with SetupDiEnumDeviceInfo, gets a bunch of information with
SetupDiGetDeviceRegistryProperty, and finds the current driver. All of that
works.

When it calls SetupDiGetDriverInstallParams, the Flags returned look
correct, but the Rank returned does not.

On XP, the Rank returned is always 0. On Vista, the Rank returned is usually
0dff0000, although for one NVidia driver it is 0dfd0000.

Comparing the Rank returned by SetupDiGetDriverInstallParams with the Rank
shown in windows\inf\setupapi.dev.log, the upper word matches, but the lower
word has been masked out. For example, the NVidia driver logs a Rank of
0dfd0001. In other words, the API is not returning the identifier score.

Is this a SetupDiGetDriverInstallParams API bug? Am I doing something
incorrectly in the call? Or is the SetupDiGetDriverInstallParams API not
intended for this scenario?

-- martin

RE: SetupDiGetDriverInstallParams returns 0 for Rank identifier score by MartinHeller

MartinHeller
Wed Mar 28 08:32:02 CDT 2007

It's sad that I have to reply to my own query, but maybe the answer will help
someone else.

It turns out that the the flags in the enclosing driver enumeration affect
how SetupDiGetDriverInstallParams behaves. To get the same Rank results as
the installer did, you need to use SPDIT_COMPATDRIVER.

if(!SetupDiBuildDriverInfoList(Devs, DevInfo, SPDIT_COMPATDRIVER)) {
//was
SPDIT_CLASSDRIVER
return FALSE;
}
if (!SetupDiEnumDriverInfo(Devs, DevInfo, SPDIT_COMPATDRIVER,
//was SPDIT_CLASSDRIVER
0, DriverInfoData)) {
return FALSE;
}

SetupDiGetDriverInstallParams(...);

-- martin


"Martin Heller" wrote:

> I have an application that is looking at existing drivers. It creates an
> HDEVINFO with all present devices using SetupDiGetClassDevs, walks through
> them with SetupDiEnumDeviceInfo, gets a bunch of information with
> SetupDiGetDeviceRegistryProperty, and finds the current driver. All of that
> works.
>
> When it calls SetupDiGetDriverInstallParams, the Flags returned look
> correct, but the Rank returned does not.
>
> On XP, the Rank returned is always 0. On Vista, the Rank returned is usually
> 0dff0000, although for one NVidia driver it is 0dfd0000.
>
> Comparing the Rank returned by SetupDiGetDriverInstallParams with the Rank
> shown in windows\inf\setupapi.dev.log, the upper word matches, but the lower
> word has been masked out. For example, the NVidia driver logs a Rank of
> 0dfd0001. In other words, the API is not returning the identifier score.
>
> Is this a SetupDiGetDriverInstallParams API bug? Am I doing something
> incorrectly in the call? Or is the SetupDiGetDriverInstallParams API not
> intended for this scenario?
>
> -- martin