QLibraryInfo/Win: use the ActiveQt-overridden handle for the main module

This applies to qaxserverdll only, where "the executable" is actually a
DLL.

Change-Id: I8ac1bc015b9e6f381de8fffd1f8ee185d923f1f4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Thiago Macieira 2025-01-16 20:25:26 -08:00
parent 64cd765531
commit 122979e3a1

View File

@ -14,6 +14,7 @@
#include "qcoreapplication.h"
#include "private/qcoreapplication_p.h"
#include "private/qfilesystementry_p.h"
#include "archdetect.cpp"
#include "qconfig.cpp"
@ -389,7 +390,9 @@ static QString getRelocatablePrefix(QLibraryInfoPrivate::UsageMode usageMode)
DWORD pathSize = GetModuleFileName(hModule, buffer, kBufferSize);
const QString qtCoreFilePath = QString::fromWCharArray(buffer, int(pathSize));
const QString qtCoreDirPath = QFileInfo(qtCoreFilePath).absolutePath();
pathSize = GetModuleFileName(NULL, buffer, kBufferSize);
hModule = reinterpret_cast<HMODULE>(QCoreApplicationPrivate::mainInstanceHandle);
pathSize = GetModuleFileName(hModule, buffer, kBufferSize);
const QString exeDirPath = QFileInfo(QString::fromWCharArray(buffer, int(pathSize))).absolutePath();
if (QFileInfo(exeDirPath) == QFileInfo(qtCoreDirPath)) {
// QtCore DLL is next to the executable. This is either a windeployqt'ed executable or an