I just had a check for the testRegisterAndGetDetail test on Vista (dunno about the other tests and platforms yet).
I added the SetupDiRemoveDevice (as was suggested by Alexander) at the end of this test.
On a clean registry this works out fine (one DeviceClasses key is left but that one can be deleted without having to fiddle with permissions).
When I however first run the old tests (with leftovers in the registry) and then run the new test again the registry keys are still present. When I do the SetupDiRemoveDevice twice at the end of testRegisterAndGetDetail the registry keys get deleted again (not that DeviceClasses key again).
So what would be a good approach? Just doing 2 SetupDiRemoveDevice's at the end to make sure old stuff is gone as well? Or doing one, check if the Enum keys is still present and then do a second SetupDiRemoveDevice (with a trace message for clarity)?
I think the second way is better. May be a number of Enum keys is equal a quantity of doing old test?