Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi sir ,


I have Disabled USB drive successfully after i tried Enable the Usb again with
but i am unable to do that can you please help on this c++ application
the below code is for Disable USB but can you help on Enable the USB code i used
SetupDiRemoveDevice
api but it is not working i dont know what i did mistake
// Get all of the devices
   //This enumeration does not work in general, instead passing
   //complete id of the device is probably best. 
   //It is helpful to know the vendor and device ID
PCTSTR enumType = "PORTS"; 
HDEVINFO devs = NULL;
devs = SetupDiGetClassDevs(NULL,enumType,0,DIGCF_ALLCLASSES);

// Loop through the devices
DWORD devCount = 0;
SP_DEVINFO_DATA devInfo;
int enumeratingDevices = 1;
/*This line is essential*/
devInfo.cbSize = sizeof(SP_DEVINFO_DATA);
while(enumeratingDevices){
        enumeratingDevices = SetupDiEnumDeviceInfo (devs,devCount,&devInfo);
        // Uninstall each device
        if(enumeratingDevices){
           SetupDiRemoveDevice(devs,&devInfo);
           devCount++;
        }
}
    //Clean up
SetupDiDestroyDeviceInfoList(devs);

What I have tried:

<pre>I have Disabled USB drive successfully after i tried Enable the Usb again
Posted
Updated 30-Jun-21 5:31am
Comments
CHill60 30-Jun-21 11:20am    
"but can you help on Enable the USB code i used" - you haven't included that code

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900