mojuba
mojuba

Reputation: 12237

Installing a driver programmatically on Windows, driver doesn't become active

I have a program that installs a USB driver for a specific device and then updates the device firmware. I use SetupCopyOEMInf() for installing the driver, however, this function doesn't seem to be making the driver active unless I restart the system.

I.e. the installation goes OK, SetupCopyOEMInf() returns OK but the device still remains "Unknown" in the Device Manager unless I restart Windows. However, when I install the driver manually, the system recognizes everything fine and the device quickly gets bound to the driver.

Is there anything else apart from SetupCopyOEMInf() I should do so that the driver gets bound to the device?

Thanks.

Upvotes: 0

Views: 1360

Answers (2)

Preston
Preston

Reputation: 2653

Try installing your driver using devcon, the source is available in the WDK, using devcon dp_add mydriver.inf. If this works you can step through the source in devcon to find out how to properly install your driver dynamically, devcon also uses SetupCopyOEMInf, so if it works you can compare this to your code to find out what the difference is, here is a snippet in case it helps you now:

TCHAR SourceInfFileName[MAX_PATH]; // Full path name
TCHAR DestinationInfFileName[MAX_PATH];
PTSTR DestinationInfFileNameComponent = NULL;

if (!SetupCopyOEMInf(SourceInfFileName,
                NULL,
                SPOST_PATH,
                0,
                DestinationInfFileName,
                ARRAYSIZE(DestinationInfFileName),
                NULL,
                &DestinationInfFileNameComponent)) {
    // Handle Error
}

Upvotes: 1

Alin
Alin

Reputation: 1

I think Device Manager restarts the device after a driver update.

Upvotes: 0

Related Questions