Searching the DDK for “ConfigFlags”, I find the below documentation.
Unfortunately, it doesn’t really answer your question, but it does
tell you the proper procedure if you can manage to figure out which
device is yours.
As you point out, It’s tricky to do this when you’re licensing to
people with different VIDs and you don’t have a device class. What
kind of device is this, anyway?
Actually, the thing I don’t understand is that you’re having this
problem while you are installing the driver, so at that time you must
know the VID/PID (or at least the set of valid VID/PIDs) in order for
the INF file to do anything… So why can’t you just look for
that/those IDs?
Anyway, here’s the doc I found:
Reinstalling an Unplugged Device
When a device that formerly was attached has been unplugged, the
device’s devnode remains in the system, although it is both inactive
and hidden. Before you can reinstall such a device, you must first
find this “phantom” devnode, and mark it as needing reinstallation.
Then, when the device is plugged back in, Plug and Play will
reenumerate the device, find the new driver for it, and install the
driver for the device.
To reinstall an unplugged device:
Call the SetupCopyOEMInf function (described in the Platform SDK
documentation).
The SetupCopyOEMInf function ensures that the correct INF file is
present in the %windir%\inf directory.
Find the unplugged devices.
Call the SetupDiGetClassDevs function. In the call to this function,
clear the DIGCF_PRESENT flag in the Flags parameter. You need to find
all devices, not just those that are present. You can narrow the
results of your search by specifying the particular device class in
the ClassGuid parameter.
Find the hardware IDs and compatible IDs of unplugged devices.
SetupDiGetClassDevs returns a handle to the device information set
that contains all installed devices, whether plugged in or not, in the
device class (assuming that you specified a device class in the first
step). By making successive calls to the SetupDiEnumDeviceInfo
function, you can use this handle to enumerate all of the devices in
the device information set. Each call provides you with an
SP_DEVINFO_DATA structure for the device. To get the list of hardware
IDs, call the SetupDiGetDeviceRegistryProperty function with the
Property parameter set to SPDRP_HARDWAREID. To get the list of the
compatible IDs, call the same function, but with the Property
parameter set to SPDRP_COMPATIBLEIDS. Both lists are MULTI-SZ strings.
Look for a match between the ID of your device and the hardware IDs
(or compatible IDs) of the previous step.
Make sure that you perform full string comparisons between the
hardware ID/compatible ID and the ID for your device. A partial
comparison can lead to inappropriate matches.
When you find a match, call the CM_Get_DevNode_Status function,
passing SP_DRVINFO_DATA.DevInst in the dnDevInst parameter. If this
function returns CR_NO_SUCH_DEVINST, that confirms that the device is
unattached (that is, has a phantom devnode).
Mark the device.
Call the SetupDiGetDeviceRegistryProperty function with the Property
parameter set to SPDRP_CONFIGFLAGS. When this function returns, the
PropertyBuffer parameter points to the device’s ConfigFlags value from
the registry. Perform a bitwise OR of this value with
CONFIGFLAG_REINSTALL (defined in regstr.h). After doing this, call the
SetupDiSetDeviceRegistryProperty function, passing SPDRP_CONFIGFLAGS.
This action modifies the registry’s ConfigFlags value to incorporate
the CONFIGFLAG_REINSTALL flag. This causes the device to be
reinstalled the next time the device is reenumerated.
Plug in the device.
Plug and Play will reenumerate the device, find the new driver for it,
and install that driver.
xxxxx@hotmail.com wrote:
Hi,
We have a usb device. If the user by mistake attaches this device to WinXp
without installing/having our software, then XP at the end of the “Found
New Hardware wizard” has a check box “Don’t prompt me again to install
this software”. This check box is enabled by default. If the user installs
our software and then attaches the device to the system, then the system
does not even care to find out the appropriate driver by looking at the
installed inf files. When this check box is set, I found that windows
creates a registry property “ConfigFlags” with a value 64 under
HKLM/System/CurrentControlSet/Enum/USB/Vid_xyz&pid_xyz/device_serial_no/.
If this registry property is deleted, then it is enumerating the device
and loading the driver.
This is an issue we need to address. A naive user does not know to go to
the device manager and unistall the device.
There is no class GUID (not even Unknown class GUID, (0x4d36e97eL, 0xe325,
0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18)) set for these
devices. I cannot find the device based on the vid and pid since our
licensees have different vid’s. Also the software has to support multiple
licensees devices.
The only solution I found out is call SetupDiGetClassDevs() for all
classes of USB devices. For each device, find out the CLASSGUID registry
property. If there is no class GUID set, delete the registry property
“ConfigFlags” if set/exists. I can do this when my software is installed.
This is kind of a hack which is not a best approach.
Is there is any other way to programmatically enable the device
enumeration/driver detection other the above mentioned?
Thanks in advance.
–
…/ray..