mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-05-02 12:39:41 +00:00
fix app path on windows
This commit is contained in:
parent
a6f3f3dd79
commit
b87e4491cd
16
params.cpp
16
params.cpp
@ -9,6 +9,11 @@
|
||||
#include <QVariantMap>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#ifdef Q_OS_WIN
|
||||
#include "windows.h"
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
using namespace QuasarAppUtils;
|
||||
|
||||
@ -27,7 +32,18 @@ void Params::verboseLog(const QString &log) {
|
||||
|
||||
bool Params::parseParams(int argc, char *argv[]) {
|
||||
params.clear();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
char buffer[MAX_PATH];
|
||||
GetModuleFileNameA(nullptr, buffer, MAX_PATH);
|
||||
params ["appPath"] = QFileInfo(buffer).absolutePath();
|
||||
#else
|
||||
params ["appPath"] = QFileInfo(argv[0]).absolutePath();
|
||||
#endif
|
||||
|
||||
if (!getStrArg("appPath").size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-' && i ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user