本帖最后由 卫和谐 于 2011-5-25 16:09 编辑
重写“防止上网沉迷系统”过程中,想放弃开机启动的方式,将软件注册成服务随机启动,可是在测试中发现,有时候运行中的程序会莫名地退出,一般是在锁定界面后,想不明白!?
在服务管理器中点击配置的服务,会显示:指定的设备实例句柄与目前设备不一致!
如果启动配置的服务的话,显示:1053,服务没有及时响应启动或控制请求!
是否和这段代码有关?While 1
HideProcess()
$OldT = _GUICtrlStatusBar_GetText($UnlockStatusbar, 1)
$NewT = _Now()
If $NewT <> $OldT Then _GUICtrlStatusBar_SetText($UnlockStatusbar, _Now(), 1)
$Gmsg4 = GUIGetMsg()
Switch $Gmsg4
Case $UnlockButton
$Password = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\PcLimit", "PassWord")
If GUICtrlRead($UnlockRadio1) = $GUI_CHECKED Then
If GUICtrlRead($UnlockInput) = "" Then
GUICtrlSetData($LockLabel, "您未输入密码!")
GUICtrlSetState($UnlockInput, $GUI_FOCUS)
ElseIf GUICtrlRead($UnlockInput) <> $Password Then
GUICtrlSetData($LockLabel, "输入密码错误!")
GUICtrlSetState($UnlockInput, $GUI_FOCUS)
ElseIf GUICtrlRead($UnlockInput) <> "" And GUICtrlRead($UnlockInput) = $Password Then
Quit()
EndIf
ElseIf GUICtrlRead($UnlockRadio2) = $GUI_CHECKED Then
If GUICtrlRead($UnlockInput) = "" Then
GUICtrlSetData($LockLabel, "您未输入密码!")
GUICtrlSetState($UnlockInput, $GUI_FOCUS)
ElseIf GUICtrlRead($UnlockInput) <> $Password Then
GUICtrlSetData($LockLabel, "输入密码错误!")
GUICtrlSetState($UnlockInput, $GUI_FOCUS)
ElseIf GUICtrlRead($UnlockInput) <> "" And GUICtrlRead($UnlockInput) = $Password Then
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PcLimit", "Runtime1", "REG_SZ", "1")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\PcLimit", "Runtime2", "REG_SZ", "1")
Quit()
EndIf
EndIf
Case $UnlockIcon
Shutdown(5)
EndSwitch
WEnd
因为也许有人会需要,所以开了新帖:http://www.autoitx.com/forum.php ... mp;extra=#pid307566 |