本帖最后由 chishingchan 于 2022-9-1 17:33 编辑
应用在这里有点出错!帮忙看看,谢谢!MsgBox(0, "", _Optimization("E:\Users\Administrator\Desktop\TEST.reg"))
Func _Optimization($sFilePath)
Local $hFileOpen = FileOpen($sFilePath, 512)
If $hFileOpen = -1 Then
Return False
EndIf
Local $sFileRead = FileRead($hFileOpen)
FileClose($hFileOpen)
;删除换行符
$sFileRead = StringReplace($sFileRead, "" & @CRLF & " ", "")
;将 \\ 替换为 \
;$sFileRead = StringReplace($sFileRead, "\", "")
;删除空行
$sFileRead =StringRegExpReplace($sFileRead, '\R+\h*(?=\R)', '')
;删除[]下没有数据的行,忽略以 [- 开头的行
$sFileRead = StringRegExpReplace($sFileRead, '(?mi)(?:^\h*\[h\V+\R+)+(?=\h*\[)', '')
;删除以 ; 开头的注释行
$sFileRead = StringRegExpReplace($sFileRead, '(?m)^\h*;\V*\R*', '')
;将 [HKEY_USERS\SID 转换为 [HKEY_CURRENT_USER
;Local $sFileRead = StringRegExpReplace($sFileRead, '(?mi)^\h*\[HKEY_USERS\\(S-1-5(?:-\d+){5})', '[HKEY_CURRENT_USER')
Return $sFileRead
EndFunc
|