I've got an old crappy VoiceMail system that connects to a Windows machine. The Windows machine keeps losing 'sync' with the hardware. When this happens, the drivers for it in device manager show yellow exclamation marks. Usually, unplugging and plugging the hardware fixes things, but I want to find an automated way. I found that if I go into device manager, and disable the 'USB Hub' for the device, and then reenable it, it fixes things. So, I want to write a program that monitors the status of the driver, and disables and reenables it when it fails. Problem is, I don't have a clue how to do it, or even if it's possible.
Is there a way to monitor, and disable/enable drivers from within Purebasic?
			
			
									
									
						Monitoring a Driver
MS has devcon.exe command-line tool, that can do what you need ...
http://support.microsoft.com/?kbid=311272
Probably you just need to wrap it around with some kind of script (cmd, wsh etc ...).
			
			
									
									
						http://support.microsoft.com/?kbid=311272
Probably you just need to wrap it around with some kind of script (cmd, wsh etc ...).
Code: Select all
OpenLibrary(1,"setupapi.dll") 
*F1 = GetFunction(1, "CM_Locate_DevNodeA") 
*F2 = GetFunction(1, "CM_Disable_DevNode") 
*F3 = GetFunction(1, "CM_Enable_DevNode")
;look in registry HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum
;to find Identifiers for PCI/USB ... Devices
id.s = "ACPI\PNP0400\5&18d3520b&0" ;sample lpt1
Debug CallFunctionFast(*F1,@devhandle,@id,0) 
Debug CallFunctionFast(*F2,devhandle,0) ;disable device
;Debug CallFunctionFast(*F3,devhandle,0) ;enable device
CloseLibrary(1)["1:0>1"]
						

