- #Region
- #AutoIt3Wrapper_icon=Z:NewDang.ico
- #AutoIt3Wrapper_Compression=5
- #AutoIt3Wrapper_Res_Comment=regedit check
- #AutoIt3Wrapper_Res_Description=regedit check
- #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
- #AutoIt3Wrapper_Res_LegalCopyright=噹噹
- #EndRegion
- #include <GUIConstantsEx.au3>
- #include <Array.au3>
- $begin = TimerInit()
- Dim $filename_A = FileOpenDialog ( "", @ScriptDir&"", "reg檔 (*.reg)", 7)
- Dim $filename_B = FileOpenDialog ( "", @ScriptDir&"", "reg檔 (*.reg)", 7)
- Dim $fin = FileOpen ($filename_A, 0)
- Dim $context, $line = 0
- If $fin = -1 Then;先讀出總數
- MsgBox( 16, "", "ERROR")
- Exit
- Else
- While True
- $context = FileReadLine($fin)
- If $context <> "" Then
- $line = $line + 1
- EndIf
- If @error = -1 Then ExitLoop
- WEnd
- FileClose($fin)
- EndIf
- Dim $regLine_A[$line]
- ;;--------------預讀A end
- $fin = FileOpen ($filename_B, 0)
- $line = 0
- If $fin = -1 Then;先讀出總數
- MsgBox( 16, "", "ERROR")
- Exit
- Else
- While True
- $context = FileReadLine($fin)
- If $context <> "" Then
- $line = $line + 1
- EndIf
- If @error = -1 Then ExitLoop
- WEnd
- FileClose($fin)
- EndIf
- Dim $regLine_B[$line]
- $dif_3 = TimerDiff($begin)
- ;;--------------預讀B end
- Dim $cnt, $Cnt2
- Dim $regPath
- Dim $regtmp
- Dim $regCR = 0
- Dim $Array_A = UBound ($regLine_A)
- $fin = FileOpen ($filename_A, 0)
- If $fin = -1 Then;先讀出總數
- MsgBox( 16, "", "ERROR")
- Else
- While True
- $Cnt2 += 1
- $context = FileReadLine($fin)
- If @error = -1 Then ExitLoop
- If $Cnt2 > $Array_A Then ExitLoop
- If StringLeft ($context, 1) = "[" And StringRight ( $context, 1) = "]" Then;; 機碼
- $context = StringTrimLeft ($context, 1);; 去掉左邊的 [
- $context = StringTrimRight ($context, 1);; 去掉右邊的 ]
- $regPath = $context
- ;~ ToolTip ($regPath)
- ElseIf StringLeft ($context, 1) = '"' Or StringLeft ($context, 1) = " " Then;;key值
- If StringLeft ($context, 1) = '"' And StringRight ( $context, 1) = "" Then;;斷行第一行
- $regCR = 1;; 落行
- $context = StringTrimRight ($context, 1);; 去掉右邊的 ]
- $context = StringStripWS($context, 3)
- $regtmp = $context
- ;~ MsgBox (0,"1", $regtmp)
- ElseIf StringLeft ($context, 1) = " " And StringRight ( $context, 1) = "" Then;;斷行
- $regCR = 1;; 落行
- $context = StringTrimLeft ($context, 1);; 去掉左邊的 [
- $context = StringTrimRight ($context, 1);; 去掉右邊的 ]
- $context = StringStripWS($context, 3)
- $regtmp = StringFormat ( "%s%s", $regtmp, $context)
- ;~ MsgBox (0,"2", $regtmp)
- ElseIf StringLeft ($context, 1) = " " Then;;斷行最後一行
- $context = StringStripWS($context, 3)
- $context = StringFormat ( "%s%s", $regtmp, $context)
- $regCR = 0;;沒斷行
- $cnt += 1
- Else
- $regCR = 0;;沒斷行
- $cnt += 1
- EndIf
- If $regCR = 0 Then;;沒斷行
- $context = StringStripCR ($context);; 去掉CR
- $regLine_A[$cnt2] = StringFormat ( "%s_%s", $regPath, $context)
- $regtmp = "";;清空斷行暫存
- ;~ ClipPut ($regLine_A[$cnt])
- ;~ MsgBox (0,"", $regLine_A[$cnt])
- ;~ ToolTip ( $Cnt2&@CRLF&@CRLF&$regLine_A[$Cnt2])
- ;~ Sleep (500)
- EndIf
- EndIf
- WEnd
- FileClose($fin)
- EndIf
- ;;--------------寫入array A end
- Dim $Array_B = UBound ($regLine_B)-1
- $regCR = 0
- $Cnt2 = 0
- $Cnt = 0
- $fin = FileOpen ($filename_B, 0)
- If $fin = -1 Then;先讀出總數
- MsgBox( 16, "", "ERROR")
- Else
- While True
- $Cnt2 += 1
- $context = FileReadLine($fin)
- If @error = -1 Then ExitLoop
- If $Cnt2 > $Array_B Then ExitLoop
- If StringLeft ($context, 1) = "[" And StringRight ( $context, 1) = "]" Then;; 機碼
- $context = StringTrimLeft ($context, 1);; 去掉左邊的 [
- $context = StringTrimRight ($context, 1);; 去掉右邊的 ]
- $regPath = $context
- ;~ ToolTip ($regPath)
- ElseIf StringLeft ($context, 1) = '"' Or StringLeft ($context, 1) = " " Then;;key值
- If StringLeft ($context, 1) = '"' And StringRight ( $context, 1) = "" Then;;斷行第一行
- $regCR = 1;; 落行
- $context = StringTrimRight ($context, 1);; 去掉右邊的 ]
- $context = StringStripWS($context, 3)
- $regtmp = $context
- ;~ MsgBox (0,"1", $regtmp)
- ElseIf StringLeft ($context, 1) = " " And StringRight ( $context, 1) = "" Then;;斷行
- $regCR = 1;; 落行
- $context = StringTrimLeft ($context, 1);; 去掉左邊的 [
- $context = StringTrimRight ($context, 1);; 去掉右邊的 ]
- $context = StringStripWS($context, 3)
- $regtmp = StringFormat ( "%s%s", $regtmp, $context)
- ;~ MsgBox (0,"2", $regtmp)
- ElseIf StringLeft ($context, 1) = " " Then;;斷行最後一行
- $context = StringStripWS($context, 3)
- $context = StringFormat ( "%s%s", $regtmp, $context)
- $regCR = 0;;沒斷行
- $cnt += 1
- Else
- $regCR = 0;;沒斷行
- $cnt += 1
- EndIf
- If $regCR = 0 Then;;沒斷行
- $context = StringStripCR ($context);; 去掉CR
- ;~ ToolTip ($cnt2)
- ;~ Sleep (10)
- $regLine_B[$cnt2] = StringFormat ( "%s_%s", $regPath, $context)
- $regtmp = "";;清空斷行暫存
- EndIf
- EndIf
- WEnd
- FileClose($fin)
- EndIf
- $dif_1 = TimerDiff($begin)
- ;;--------------寫入array B end
- For $i = 0 To $Array_A-1
- If $regLine_A[$i] = "" Then ContinueLoop
- For $j = 0 To UBound ($regLine_B)-1
- If $regLine_A[$i] = $regLine_B[$j] Then
- ;~ MsgBox ( 0, "i:"&$i&"___:j"&$j, $regLine_A[$i]&@CR&$regLine_B[$j])
- $regLine_A[$i] = ""
- $regLine_B[$j] = ""
- ExitLoop(1)
- EndIf
- Next
- Next
- $dif_4 = TimerDiff($begin)
- ;;--------------比對Array end
- const $output_A= "my_output_A.txt"
- const $output_B= "my_output_B.txt"
- $fout = FileOpen($output_A, 2)
- For $i=0 To UBound ($regLine_A)-1
- FileWriteLine($fout, $i&"__"&$regLine_A[$i])
- Next
- FileClose($fout)
- $fout = FileOpen($output_B, 2)
- For $i=0 To UBound ($regLine_B)-1
- FileWriteLine($fout, $i&"__"&$regLine_B[$i])
- Next
- $dif_2 = TimerDiff($begin)
- FileWriteLine($fout, StringFormat ("read time:%s sec", $dif_3/1000))
- FileWriteLine($fout, StringFormat ("write memory time:%s sec", $dif_1/1000))
- FileWriteLine($fout, StringFormat ("search time:%s sec", $dif_4/1000))
- FileWriteLine($fout, StringFormat ("write file time:%s sec", $dif_2/1000))
- FileClose($fout)
複製代碼 |