|
本帖最后由 yngwcc 于 2012-5-9 12:52 编辑
我是新手 照着写的 不知道错在哪里? 谢谢
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <Array.au3>
;_DrvUnins_ReadHwinds()
;_DrvUnins_TidyHwids()
;_DrvUnins_Unins()
Func _DrvUnins_ReadHwinds()
Local $HwidList[1][2],$p = 1
Local $RootKey = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum"
Local $i = 1
While 1
Local $SubKey1 = RegEnumKey($RootKey,$i)
If @error = -1 Then ExitLoop
$SubKey1 = $RootKey & "\" & $SubKey1
Local $j = 1
While 1
Local $SubKey2 = RegEnumKey($SubKey1,$j)
If @error = -1 Then ExitLoop
$SubKey2 = $SubKey1 & "\" & $SubKey2
Local $k = 1
While 1
Local $SubKey3 = RegEnumKey($SubKey2,$k)
If @error = -1 Then ExitLoop
$SubKey3 = $SubKey2 & "\" & $SubKey3
Local $CLs = RegRead($SubKey3,"Class")
If $CLs <> "Mouse" And _
$CLs <> "Keyboard" And _
$CLs <> "System" And _
$CLs <> "LegacyDriver" And _
$CLs <> "Computer" And _
$CLs <> "" Then
ReDim $HwidList[$p + 1][2]
$HwidList[$p][0] = $SubKey3
$HwidList[$p][1] = RegRead($SubKey3,"HardwareID")
$p += 1
EndIf
$k += 1
WEnd
$j += 1
WEnd
$i += 1
WEnd
Return $HwidList
EndFunc
Func _DrvUnins_TidyHwids($HwidList)
Local $tHwidList[1],$tp = 1
Local $i
For $i = 1 To UBound($HwidList,1) - 1
Local $Hwids = $HwidList[$i][1]
If $Hwids <> "" Then
Local $tArr = StringSplit($Hwids,@LF)
If IsArray($tArr) And $tArr[0] > 1 Then
Local $j
For $j = 1 To UBound($tArr) - 1
ReDim $tHwidList[$tp + 1]
$tHwidList[$tp] = $tArr[$j]
$tp += 1
Next
EndIf
EndIf
Next
_ArrayDisplay($tHwidList)
Local $i, $j
For $i = 1 To UBound($tHwidList) - 2
For $j = $i + 1 To UBound($tHwidList) - 1
If $tHwidList[$i] <> "" And _
$tHwidList[$i] = $tHwidList[$j] Then
$HwidList[$j] = ""
EndIf
Next
Next
;_ArrayDisplay($HwidList)
Local $Hwids[1],$p = 1
Local $i
For $i = 1 To UBound($tHwidList) - 1
If $tHwidList[$i] <> "" Then
ReDim $Hwids[$p + 1]
$Hwids[$p] = $tHwidList[$i]
$p += 1
EndIf
Next
;_ArrayDisplay($Hwids)
Return $Hwids
EndFunc
Func _DrvUnins_Unins($Hwids)
ProgressOn("驱动卸载","正在卸载驱动...")
Local $i
Local $Max = UBound($Hwids) - 1
Local $per = 1
For $i = 1 To $Max
$per = Int($i / $Max * 100)
ProgressSet($per,StringReplace($Hwids[$i],"&","&&"),"正在卸载驱动...(" & $per & "%)")
RunWait("devcon.exe" & " remove " & $Hwids[$i],"",@SW_SHOW)
Next
ProgressOff()
EndFunc |
|