GetLogicalVolumes wait for Idleness

Hi, I am using SetupDiSetClassInstallParams() to disable/enable usb device. Immediately after enabling, I check for all volumes with GetLogicalVolumes, but it does not return freshly enabled usb 's letter as 1 . I do not want to use Sleep(). Waiting for event DBT_DEVICEARRIVAL won’t work because there might be N number of usb’s disabled and enabled at the same time, and we might not know which DBT_DEVICEARRIVAL is the last one. Closest thing I found is this , but it says do not use. Any ideas?

There’s really no definitive solution to this problem., so you’re stuck with a heuristic.

When it comes to such heuristics, simpler is generally better. If it were me,I’d use sleep.


Device discovery is an asynchronous process. You’re triggering it, but the processing all happens in the background. Don’t you know how many devices to expect? You can keep probing for the whole set during every DBT_DEVICEARRIVAL call.