From f6bcb86aab922f1fae8b47803d9affcd7832ee75 Mon Sep 17 00:00:00 2001 From: Pepa Rokos Date: Wed, 31 May 2017 19:08:01 +0200 Subject: [PATCH] Application adds path to plugins to environment variable PATH on startup. Plugin loading is working correct now. --- application/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/application/main.cpp b/application/main.cpp index 7712bbc..d15d3a0 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -4,10 +4,26 @@ #include #include +#ifdef _WIN32 +#include +#endif + int main(int argc, char *argv[]) { QApplication a(argc, argv); +#ifdef _WIN32 + QString exePath = a.applicationDirPath(); + exePath = exePath.append("\\plugins"); + + wchar_t Path[10000]; + ::GetEnvironmentVariable(L"PATH", Path, sizeof(Path) / sizeof(TCHAR)); + QString pathVar = QString::fromWCharArray(Path); + QString newPath = exePath.append(";").append(pathVar); + + ::SetEnvironmentVariable(TEXT("PATH"), newPath.toStdWString().c_str()); +#endif + QTranslator qtTranslator; qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));