check vc redist in runtime

This commit is contained in:
Nova 2025-03-22 21:47:39 +03:30
parent fec85a54ec
commit 9f89e48733
5 changed files with 26 additions and 2 deletions

View File

@ -209,6 +209,8 @@ set(PROJECT_SOURCES
include/stats/connections/connectionLister.hpp
src/stats/connectionLister/connectionLister.cpp
src/configs/proxy/Json2Bean.cpp
include/sys/windows/vcCheck.h
src/sys/windows/vcCheck.cpp
)
# Qt exe

View File

@ -0,0 +1,3 @@
#pragma once
bool checkVCRedist();

View File

@ -12,6 +12,7 @@
#include <3rdparty/WinCommander.hpp>
#include "include/global/NekoGui.hpp"
#include "include/sys/windows/vcCheck.h"
#include "include/ui/mainwindow_interface.h"
@ -68,6 +69,14 @@ int main(int argc, char* argv[]) {
QApplication::setQuitOnLastWindowClosed(false);
QApplication a(argc, argv);
#ifdef Q_OS_WIN
if (!checkVCRedist())
{
QMessageBox::critical(nullptr, "Cannot run Nekoray", "You need to install VC 2022 Redistributable, Download it from: https://aka.ms/vs/17/release/vc_redist.x64.exe");
return 1;
}
#endif
// Clean
QDir::setCurrent(QApplication::applicationDirPath());
if (QFile::exists("updater.old")) {
@ -162,7 +171,7 @@ int main(int argc, char* argv[]) {
dir_success &= dir.mkdir(RULE_SETS_DIR);
}
if (!dir_success) {
QMessageBox::warning(nullptr, "Error", "No permission to write " + dir.absolutePath());
QMessageBox::critical(nullptr, "Error", "No permission to write " + dir.absolutePath());
return 1;
}

View File

@ -55,7 +55,7 @@ LONG __stdcall CreateCrashHandler(EXCEPTION_POINTERS *pException) {
dumpText = "";
}
// 创建消息提示
QMessageBox::warning(NULL, "Application crashed",
QMessageBox::critical(NULL, "Application crashed",
QString("ErrorCode: %1 ErrorAddr:%2 ErrorFlag: %3 ErrorPara: %4\nVersion: %5\nDump file at %6")
.arg(errCode)
.arg(errAddr)

View File

@ -0,0 +1,10 @@
#include <include/sys/windows/vcCheck.h>
#include <QSettings>
bool checkVCRedist()
{
QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64", QSettings::NativeFormat);
return (settings.value("Installed").toInt() == 1);
}