//关闭屏幕保护 if(this->m_bScreenSaver) { SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, false, 0, 0); bool bAct; SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, &bAct, 0); if (bAct) { sendText(m_number,"屏幕保护禁止失败.",1); } else { sendText(m_number,"屏幕保护已经禁止."); } } //禁止电源管理的睡眠功能 if(this->m_bPowerMan){ SetThreadExecutionState( ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED ); sendText(m_number,"电源管理的睡眠功能已经禁止."); } //设置虚拟内存 //设置分辨率 if(this->m_bResolution){ DEVMODE dmScreenSettings; // 设备模式 memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // 确保内存清空为零 dmScreenSettings.dmSize = sizeof(dmScreenSettings); // DEVMODE结构的大小 dmScreenSettings.dmPelsWidth = this->m_sResolutionWidth.toInt(); // 所选屏幕宽度 dmScreenSettings.dmPelsHeight = this->m_sResolutionHeight.toInt(); // 所选屏幕高度 //dmScreenSettings.dmBitsPerPel = m_BitsPerPixel; // 每象素所选的色彩深度 dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; // 尝试设置显示模式并返回结果,注:CDS_FULLSCREEN 移去了状态条 if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { //设置失败 sendText(m_number,tr("设置分辨率失败"),1);//设置分辨率成功 }else{ sendText(m_number,tr("设置分辨率成功"));//设置分辨率成功 } } //将一直提醒关闭相关进程,直到关闭为止 if(this->m_bUninstallKiller){ //卸载清单 QList<QString> lsUninstallList; lsUninstallList.append("ravmond.exe");//瑞星进程 lsUninstallList.append("rstray.exe"); lsUninstallList.append("rsmain.exe"); lsUninstallList.append("KVMonXP.kxp");//江民进程 lsUninstallList.append("kvsrvxp.exe"); lsUninstallList.append("kvxp.kxp"); lsUninstallList.append("360rp.exe");//360进程 lsUninstallList.append("360sd.exe"); lsUninstallList.append("360tray.exe"); lsUninstallList.append("ZhuDongFangYu.exe"); lsUninstallList.append("KMService.exe");//金山毒霸进程 lsUninstallList.append("kxescore.exe"); lsUninstallList.append("kxetray.exe"); lsUninstallList.append("QQPCTray.exe");//电脑管家进程 lsUninstallList.append("QQPCRTP.exe"); lsUninstallList.append("QQPCMgr.exe"); QList<QString> lsProcessList; while(true){ lsProcessList.clear(); HANDLE hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); if(hProcessSnap==INVALID_HANDLE_VALUE){ return; } PROCESSENTRY32 pe32; pe32.dwSize = sizeof(PROCESSENTRY32); //遍历进程快照。轮流显示每个进程的信息 BOOL bMore=Process32First(hProcessSnap,&pe32); while(bMore){ bMore=Process32Next(hProcessSnap,&pe32); lsProcessList.append(QString::fromWCharArray(pe32.szExeFile)); } //清除snapshot对象 CloseHandle(hProcessSnap); bool bFlag = true; for(int i=0;i<lsProcessList.size();i++){ if(lsUninstallList.contains(lsProcessList.at(i))){ bFlag=false; CustomMessageBox::info(QObject::tr("tips"), tr("发现需要关闭的进程:")+lsProcessList.at(i)+tr("请卸载."));//发现进程: ,请卸载 } } if(bFlag) break; } } QString sApplicationPath = m_lsCopyList.at(i).m_sDstPath; QStringList list = sApplicationPath.split(QRegExp("[\\\\/]")); QString sApplicationName = list.at(list.size()-1); if(m_lsCopyList.at(i).m_bShortcut){ if(QFile::link(sApplicationPath,QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)+"\\"+sApplicationName+".lnk")){ emit sendText(m_number,tr("设置快捷方式成功."));//设置快捷方式成功 } } QSettings *pSettings = new QSettings(REG_RUN, QSettings::NativeFormat); if(m_lsCopyList.at(i).m_bAutorun) { pSettings->setValue(sApplicationName, sApplicationPath.replace("/", "\\")); emit sendText(m_number,tr("设置自启动项成功."));//设置自启动项成功 } else { pSettings->remove(sApplicationName); } delete pSettings; //设置直接执行 if(m_lsCopyList.at(i).m_bExecute) { QProcess *process = new QProcess; process->startDetached(m_lsCopyList.at(i).m_sDstPath); emit sendText(m_number,tr("该程序已经开始运行.")); }
时间: 2024-11-11 12:54:33