This commit is contained in:
DavidXanatos 2024-04-26 09:16:12 +02:00
parent ee7d48700a
commit b27b4b5eda
2 changed files with 45 additions and 1 deletions

View File

@ -127,4 +127,46 @@ void ProtectWindow(void* hWnd)
pSetWindowDisplayAffinity = (LPSETWINDOWDISPLAYAFFINITY)GetProcAddress(LoadLibraryA("user32.dll"), "SetWindowDisplayAffinity");
if (pSetWindowDisplayAffinity)
pSetWindowDisplayAffinity((HWND)hWnd, 0x00000011);
}
QString GetProductVersion(const QString &filePath)
{
QFileInfo check_file(filePath);
// check if file exists and if yes: Is it really a file and no directory?
if (check_file.exists() && check_file.isFile()) {
DWORD verHandle = 0;
UINT size = 0;
LPBYTE lpBuffer = NULL;
DWORD verSize = GetFileVersionInfoSize(filePath.toStdWString().c_str(), &verHandle);
if (verSize != NULL) {
LPSTR verData = new char[verSize];
if (GetFileVersionInfo(filePath.toStdWString().c_str(), verHandle, verSize, verData)) {
if (VerQueryValue(verData, L"\\", (VOID FAR* FAR*)&lpBuffer, &size)) {
if (size) {
VS_FIXEDFILEINFO *verInfo = (VS_FIXEDFILEINFO *)lpBuffer;
if (verInfo->dwSignature == 0xfeef04bd) {
// Doesn't matter if you are on 32 bit or 64 bit,
// DWORD is always 32 bits, so first two revision numbers
// come from dwFileVersionMS, last two come from dwFileVersionLS
QString Version = QString("%1.%2.%3")
.arg((verInfo->dwFileVersionMS >> 16) & 0xffff)
.arg((verInfo->dwFileVersionMS >> 0) & 0xffff)
.arg((verInfo->dwFileVersionLS >> 16) & 0xffff)
//.arg((verInfo->dwFileVersionLS >> 0) & 0xffff)
;
DWORD Update = (verInfo->dwFileVersionLS >> 0) & 0xffff;
if (Update)
Version += QString("%1").arg(QChar((char)('a' + (Update - 1))));
return Version;
}
}
}
}
delete[] verData;
}
}
return QString();
}

View File

@ -6,4 +6,6 @@ QPixmap LoadWindowsIcon(const QString& Path, quint32 Index);
bool PickWindowsIcon(QWidget* pParent, QString& Path, quint32& Index);
void ProtectWindow(void* hWnd);
void ProtectWindow(void* hWnd);
QString GetProductVersion(const QString& filePath);