@@ -37,14 +37,22 @@ Func _Cleaner()
3737
3838 ; Scan
3939 Local $iTotalFound = 0
40+ Local $bCanceled = False
4041 For $sRoot In $aTargets
41- __Registry_Scan_Recursive($sRoot , $sSearchTerm , $idListView , $iTotalFound , $idStatus )
42+ __Registry_Scan_Recursive($sRoot , $sSearchTerm , $idListView , $iTotalFound , $idStatus , $idBtnCancel )
43+ If @error Or GUIGetMsg () = $idBtnCancel Then
44+ $bCanceled = True
45+ EndIf
4246 Next
43- GUICtrlSetData ($idStatus , " Scan complete. Found " & $iTotalFound & " keys." )
47+ If $bCanceled = True Then
48+ GUICtrlSetData ($idStatus , " Scan canceled. Found " & $iTotalFound & " keys." )
49+ Else
50+ GUICtrlSetData ($idStatus , " Scan complete. Found " & $iTotalFound & " keys." )
51+ EndIf
4452
4553 While 1
4654 Switch GUIGetMsg ()
47- Case $GUI_EVENT_CLOSE , $idBtnCancel
55+ Case $GUI_EVENT_CLOSE
4856 Exit
4957
5058 Case $idBtnDelete
@@ -70,14 +78,15 @@ Func _Cleaner()
7078EndFunc ; ==>_Cleaner
7179
7280; ---------------------------------------------------------------------------------------
73- Func __Registry_Scan_Recursive($sKey , $sSearch , $hLV , ByRef $iCount , $idStatus )
81+ Func __Registry_Scan_Recursive($sKey , $sSearch , $hLV , ByRef $iCount , $idStatus , $idBtnCancel )
7482 Local $iIndex = 1
7583 While 1
7684 Local $sSubKey = RegEnumKey ($sKey , $iIndex )
7785 If @error Then ExitLoop
7886
7987 If Mod ($iIndex , 100 ) = 0 Then
8088 GUICtrlSetData ($idStatus , " Scanning: " & $iIndex & " keys in " & StringLeft ($sKey , 40 ) & " ..." )
89+ If GUIGetMsg () = $idBtnCancel Then Return SetError (1 )
8190 EndIf
8291
8392 Local $sFull = $sKey & " \" & $sSubKey
@@ -90,7 +99,9 @@ Func __Registry_Scan_Recursive($sKey, $sSearch, $hLV, ByRef $iCount, $idStatus)
9099 _GUICtrlListView_SetItemChecked($hLV , _GUICtrlListView_GetItemCount($hLV ) - 1 )
91100 EndIf
92101
93- __Registry_Scan_Recursive($sFull , $sSearch , $hLV , $iCount , $idStatus )
102+ __Registry_Scan_Recursive($sFull , $sSearch , $hLV , $iCount , $idStatus , $idBtnCancel )
103+ If @error Then Return SetError (1 )
104+
94105 $iIndex += 1
95106 WEnd
96107EndFunc ; ==>__Registry_Scan_Recursive
@@ -107,3 +118,4 @@ Func __Delete_Checked_Items($hLV)
107118 EndIf
108119 Next
109120EndFunc ; ==>__Delete_Checked_Items
121+ ; ---------------------------------------------------------------------------------------
0 commit comments