#include <SetupApi.au3>
Clear_Ghost_Hardware()
Func Clear_Ghost_Hardware()
Local $Enum, $x, $y, $z, $ID1, $ID2, $ID3, $EnID,$hDevs, $tDevInfo
$Enum = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum"
$x = 1
While 1
$ID1 = RegEnumKey($Enum, $x)
If @error = -1 Then ExitLoop
If StringInStr($ID1, "USB") = 0 And StringInStr($ID1, "Root") = 0 And StringInStr($ID1, "SW") = 0 Then
$y = 1
While 1
$ID2 = RegEnumKey($Enum & "" & $ID1, $y)
If @error = -1 Then ExitLoop
$z = 1
While 1
$ID3 = RegEnumKey($Enum & "" & $ID1 & "" & $ID2, $z)
If @error <> 0 Then ExitLoop
RegRead($Enum & "" & $ID1 & "" & $ID2 & "" & $ID3 & "\Control", "hdj")
If @error = 1 Then
$EnID = $ID1 & "" & $ID2 & "" & $ID3
MsgBox(64, "", $EnID)
_SetupDiCreateDeviceDevs($EnID, $hDevs, $tDevInfo)
_SetupDiRemoveDevice($hDevs, $tDevInfo, True)
_SetupDiDestroyDeviceInfoList($hDevs)
DllCall("shell32.dll", "none", "SHChangeNotify", "long", 0x8000000, "int", 0, "ptr", 0, "ptr", 0)
EndIf
$z += 1
WEnd
$y += 1
WEnd
EndIf
$x += 1
WEnd
EndFunc ;==>Clear_Ghost_Hardware
|