@@ -424,7 +424,7 @@ void MainWindow::on_btnCleanNow_clicked()
424424 memAfter.dwLength = sizeof (MEMORYSTATUSEX);
425425 GlobalMemoryStatusEx (&memAfter);
426426
427- double cleaned = (memAfter.ullAvailPhys - memBefore.ullAvailPhys ) / (1024.0 * 1024 );
427+ double cleaned = (( long long ) memAfter.ullAvailPhys - ( long long ) memBefore.ullAvailPhys ) / (1024.0 * 1024 );
428428 ui->textBrowser ->append (tr (" [%1] 已清理内存: %2 MB" )
429429 .arg (QDateTime::currentDateTime ().toString (" hh:mm:ss" ))
430430 .arg (cleaned, 0 , ' f' , 1 ));
@@ -791,16 +791,14 @@ void MainWindow::setAutoStart(bool enable)
791791 LPCWSTR keyPath = L" SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Run" ;
792792 LPCWSTR appName = L" MemoryCleaner" ;
793793
794- // 获取应用程序的完整路径
794+
795795 wchar_t exePath[MAX_PATH];
796796 GetModuleFileNameW (NULL , exePath, MAX_PATH);
797797
798798 if (RegOpenKeyExW (HKEY_CURRENT_USER, keyPath, 0 , KEY_WRITE, &hKey) == ERROR_SUCCESS) {
799799 if (enable) {
800- // 添加开机自启动
801800 RegSetValueExW (hKey, appName, 0 , REG_SZ, (BYTE*)exePath, (wcslen (exePath) + 1 ) * sizeof (wchar_t ));
802801 } else {
803- // 删除开机自启动
804802 RegDeleteValueW (hKey, appName);
805803 }
806804 RegCloseKey (hKey);
@@ -810,7 +808,7 @@ void MainWindow::setAutoStart(bool enable)
810808 ui->actionAutoStart ->setChecked (enable);
811809}
812810
813- // 检查是否已设置开机自启动
811+
814812bool MainWindow::isAutoStartEnabled ()
815813{
816814 HKEY hKey;
@@ -849,13 +847,13 @@ void MainWindow::onEnableMessageTriggered()
849847 bool enabled = ui->actionEnableMessage ->isChecked ();
850848 enableMessage = enabled;
851849
852- // 保存设置
850+
853851 QString iniPath = QCoreApplication::applicationDirPath () + " /settings.ini" ;
854852 QSettings settings (iniPath, QSettings::IniFormat);
855853 settings.setValue (" enableMessage" , enabled);
856854 settings.sync ();
857855
858- // 显示提示消息(仅在开启通知时显示)
856+
859857 if (enabled) {
860858 QString message = enabled ? tr (" 已开启通知消息" ) : tr (" 已关闭通知消息" );
861859 trayIcon->showMessage (" MemoryCleaner" , message, QSystemTrayIcon::Information, 2000 );
0 commit comments