From 9ee981ae069ab8fbda3292ef1748190a141e3241 Mon Sep 17 00:00:00 2001 From: Zhong Yang Date: Mon, 17 May 2021 20:50:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=AE=BE=E7=BD=AE=E5=BC=80?= =?UTF-8?q?=E6=9C=BA=E5=90=AF=E5=8A=A8=E5=A4=B1=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TrafficMonitor/TrafficMonitor.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/TrafficMonitor/TrafficMonitor.cpp b/TrafficMonitor/TrafficMonitor.cpp index 29fd333a3..dd8b92c3a 100644 --- a/TrafficMonitor/TrafficMonitor.cpp +++ b/TrafficMonitor/TrafficMonitor.cpp @@ -594,6 +594,9 @@ void CTrafficMonitorApp::SetAutoRunByRegistry(bool auto_run) } if (auto_run) //写入注册表项 { + //通过注册表设置开机自启动项时删除计划任务中的自启动项 + SetAutoRunByTaskScheduler(false); + if (key.SetStringValue(_T("TrafficMonitor"), m_module_path_reg.c_str()) != ERROR_SUCCESS) { AfxMessageBox(CCommon::LoadText(IDS_AUTORUN_FAILED_NO_ACCESS), MB_OK | MB_ICONWARNING); @@ -613,20 +616,21 @@ void CTrafficMonitorApp::SetAutoRunByRegistry(bool auto_run) return; } } - - //通过注册表设置开机自启动项时删除计划任务中的自启动项 - SetAutoRunByTaskScheduler(false); } void CTrafficMonitorApp::SetAutoRunByTaskScheduler(bool auto_run) { if (auto_run) + { + //通过计划任务设置开机自启动项时删除注册表中的自启动项 + SetAutoRunByRegistry(false); + create_auto_start_task_for_this_user(true); + } else + { delete_auto_start_task_for_this_user(); - - //通过计划任务设置开机自启动项时删除注册表中的自启动项 - SetAutoRunByRegistry(false); + } } CString CTrafficMonitorApp::GetSystemInfoString()