Windows USB device refresh in C\C++

I am trying to find a way to programmatically re-enumerate the USB devices connected to the USB ports of a pc.  In windows XP, it is possible to open the Device Manager, right click on the PC name and select "Scan for Hardware Changes".  How can I execute this (or something similar but specific to the USB bus) from a C\C++ program?  MSDN website is not helpful.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

monstro281Author Commented:
Got it.
BOOL ScanForHardwareChanges() 
    DEVINST     devInst;
    CONFIGRET   status;
    // Get the root devnode.
    status = CM_Locate_DevNode(&devInst, NULL, CM_LOCATE_DEVNODE_NORMAL);
    if (status != CR_SUCCESS) {
        printf("CM_Locate_DevNode failed: %x\n", status);
        return FALSE;
    status = CM_Reenumerate_DevNode(devInst, 0);
    if (status != CR_SUCCESS) {
        printf("CM_Reenumerate_DevNode failed: %x\n", status));
        return FALSE;
    return TRUE;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.