Skip to content

Commit

Permalink
修正设置开机启动失效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyang219 committed May 17, 2021
1 parent a5b8c6c commit 9ee981a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions TrafficMonitor/TrafficMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand Down

0 comments on commit 9ee981a

Please sign in to comment.