Is it possible to programmatically uninstall a device in windows and perform a 'scan for hardware changes' programmatically? Is there any VB script that can be used for the same? Or is there any windows API that can be called to achieve the same?
Asked
Active
Viewed 5,682 times
1 Answers
4
To force the 'scan for hardware changes' checkout "How To Force Reenumeration of a Device Tree From an Application" the sample there shows how to force the entire tree to be re-enumerated.
As to removing a driver checkout DiUninstallDevice.

Stephen Klancher
- 1,374
- 15
- 24

Ruddy
- 1,734
- 10
- 11
-
Hi Ruddy, Thank you very much for the post. I will try out the links that you had pointed to. Regards Ananth – Ananth Padmanabhan C B Feb 02 '10 at 11:16
-
Hi, Thank you so much for the response. I was trying to execute the program in the link, http://support.microsoft.com/kb/259697 But I found out that this requires the file cfgmgr32.lib to be included. I was unable to find that file anywhere in my SDK folders, nor in the internet. Can you please guide me in this regard? Regards Ananth – Ananth Padmanabhan C B Feb 08 '10 at 11:15
-
@AnanthPadmanabhanCB I was able to include the Cfmgr32.lib by placing the following call in my source code: `#pragma comment(lib, "Cfgmgr32.lib")` – user3731622 Sep 11 '15 at 22:41
-
@Ruddy Does using the 'scan for hardware changes' code you're comment mentions cause the Device Manager->Disk Drives to show a new hard drive? I need to get the new hard drive to trigger off a windows message like `WM_DEVICECHANGE` for most likely the event `DBT_DEVICEARRIVAL`? – user3731622 Sep 11 '15 at 22:46