I have Windows WDF device driver code, trying to make it work to preinstall (before the device is present). It starts by checking for the presence of valid device IDs, and for any that are found it does this:
if (UpdateDriverForPlugAndPlayDevices(0, // No Window Handle
hwid, // Hardware ID
inffile, // FileName
INSTALLFLAG_FORCE,
&RebootRequired))
// success
But if no devices are present / plugged in, it does this:
if(SetupCopyOEMInf(inffile,
NULL,
SPOST_PATH,
0,
NULL,
0,
NULL,
NULL))
// etc.
In the first case (device present), all is good. But in the second case, according to Microsoft's "Preinstalling Driver Packages", it should to copy the INF to c:\Windows\inf\oem.inf (which it does) then once a device is present, it should install the driver based on the info in the INF, which it does not, and I have to go to the device manager, remove the unknown device, and scan for hardware changes to make it install.
In the first case (device present), our driver .sys file gets copied to the c:\windows\system32\drivers dir, whereas in the second case it never does. If I just separately copy the .sys file to c:\windows\system32\drivers, everything works. I can just do that but that seems kludgey (and risky) given that it's all supposed to be handled automatically, based on my reading of Microsoft's "Preinstalling Driver Packages" doc.