mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-19 05:30:06 +08:00
check vc redist in runtime
This commit is contained in:
parent
fec85a54ec
commit
9f89e48733
@ -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
|
||||
|
||||
3
include/sys/windows/vcCheck.h
Normal file
3
include/sys/windows/vcCheck.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
bool checkVCRedist();
|
||||
11
src/main.cpp
11
src/main.cpp
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
10
src/sys/windows/vcCheck.cpp
Normal file
10
src/sys/windows/vcCheck.cpp
Normal 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);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user