不用那么复杂,你的问题是修改完注册表后没有生效的原因
想让它生效只需要启动一下IE就可以了;================================================================
;注册表检查
;================================================================
Func _Regedit($KeyPath_1, $KeyName_1, $KeyType_1, $KeyValue_1, $r_Flag_1)
Local $Oper_flag=0
If $r_Flag_1 = 1 Then
$reg_text = RegRead($KeyPath_1, $KeyName_1)
If @error <> 0 Or $reg_text <> $KeyValue_1 Then
RegWrite($KeyPath_1, $KeyName_1, $KeyType_1, $KeyValue_1)
If $logFlag = 1 Then write_log("注册表写入成功: " & $KeyValue_1)
$Oper_flag=1
EndIf
Else
RegRead($KeyPath_1, $KeyName_1)
If @error = 0 Then
RegDelete($KeyPath_1, $KeyName_1)
If $logFlag = 1 Then write_log("注册表删除成功")
$Oper_flag=2
EndIf
EndIf
If $logFlag = 1 Then write_log("注册表自启动检查完成")
Return $Oper_flag
EndFunc ;==>_Regedit
Local $regedit_oper1, $regedit_oper2
$regedit_oper1 = _Regedit("HKEY_CLASSES_ROOT\http\shell\open\command", "", "REG_SZ", @ProgramFilesDir & "\Internet Explorer\iexplore.exe", 1)
$regedit_oper2 = _Regedit("HKEY_CLASSES_ROOT\http\shell\open\ddeexec\Application", "", "REG_SZ", "iexplore.exe", 1)
If $regedit_oper1 = 1 Or $regedit_oper2 = 1 Then ShellExecute("iexplore.exe", "", "", "open")
我使用这种方法解决了目前的问题,但是有一点,就是如果检测到非IE的浏览器后,要修改注册表,然后要启动一下IE使它生效,需要手动关闭,如果想完美一点,可以取到进程ID然后杀掉它。 |