mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-28 03:35:38 +08:00
Use QString::arg() instead of QString::sprintf()
QString::sprintf() and also QString::asprintf are both not recommended to be used in new code. refs #918
This commit is contained in:
committed by
Mathew Sutcliffe
parent
87420e7890
commit
a92a9f13f4
@@ -82,41 +82,39 @@ namespace BlackMisc
|
|||||||
dwSize = GetFileVersionInfoSize(pszFilePath, NULL);
|
dwSize = GetFileVersionInfoSize(pszFilePath, NULL);
|
||||||
if (dwSize == 0)
|
if (dwSize == 0)
|
||||||
{
|
{
|
||||||
result.errorMsg.sprintf("Error in GetFileVersionInfoSize: %d\n", GetLastError());
|
result.errorMsg = QString("Error in GetFileVersionInfoSize: %1\n").arg(GetLastError());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<BYTE> pbVersionInfo(dwSize);
|
std::vector<BYTE> pbVersionInfo(dwSize);
|
||||||
if (!GetFileVersionInfo(pszFilePath, 0, dwSize, pbVersionInfo.data()))
|
if (!GetFileVersionInfo(pszFilePath, 0, dwSize, pbVersionInfo.data()))
|
||||||
{
|
{
|
||||||
result.errorMsg.sprintf("Error in GetFileVersionInfo: %d\n", GetLastError());
|
result.errorMsg = QString("Error in GetFileVersionInfo: %1\n").arg(GetLastError());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Language independent version of VerQueryValue
|
// Language independent version of VerQueryValue
|
||||||
if (!VerQueryValue(pbVersionInfo.data(), TEXT("\\"), reinterpret_cast<LPVOID *>(&pFileInfo), &puLenFileInfo))
|
if (!VerQueryValue(pbVersionInfo.data(), TEXT("\\"), reinterpret_cast<LPVOID *>(&pFileInfo), &puLenFileInfo))
|
||||||
{
|
{
|
||||||
result.errorMsg.sprintf("Error in VerQueryValue: %d\n", GetLastError());
|
result.errorMsg = QString("Error in VerQueryValue: %1\n").arg(GetLastError());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pFileInfo->dwFileVersionMS is usually zero.
|
// pFileInfo->dwFileVersionMS is usually zero.
|
||||||
// However, you should check this if your version numbers seem to be wrong
|
// However, you should check this if your version numbers seem to be wrong
|
||||||
result.fileVersion.sprintf("%d.%d.%d.%d",
|
result.fileVersion = QString("%1.%2.%3.%4")
|
||||||
(pFileInfo->dwFileVersionMS >> 16) & 0xffff,
|
.arg((pFileInfo->dwFileVersionMS >> 16) & 0xffff)
|
||||||
(pFileInfo->dwFileVersionMS >> 0) & 0xffff,
|
.arg((pFileInfo->dwFileVersionMS >> 0) & 0xffff)
|
||||||
(pFileInfo->dwFileVersionLS >> 16) & 0xffff,
|
.arg((pFileInfo->dwFileVersionLS >> 16) & 0xffff)
|
||||||
(pFileInfo->dwFileVersionLS >> 0) & 0xffff
|
.arg((pFileInfo->dwFileVersionLS >> 0) & 0xffff);
|
||||||
);
|
|
||||||
|
|
||||||
// pFileInfo->dwProductVersionMS is usually zero. However, you should check
|
// pFileInfo->dwProductVersionMS is usually zero. However, you should check
|
||||||
// this if your version numbers seem to be wrong
|
// this if your version numbers seem to be wrong
|
||||||
result.productVersion.sprintf("%d.%d.%d.%d",
|
result.productVersion = QString("%1.%2.%3.%4")
|
||||||
(pFileInfo->dwProductVersionMS >> 16) & 0xffff,
|
.arg((pFileInfo->dwProductVersionMS >> 16) & 0xffff)
|
||||||
(pFileInfo->dwProductVersionMS >> 0) & 0xffff,
|
.arg((pFileInfo->dwProductVersionMS >> 0) & 0xffff)
|
||||||
(pFileInfo->dwProductVersionLS >> 16) & 0xffff,
|
.arg((pFileInfo->dwProductVersionLS >> 16) & 0xffff)
|
||||||
(pFileInfo->dwProductVersionLS >> 0) & 0xffff
|
.arg((pFileInfo->dwProductVersionLS >> 0) & 0xffff);
|
||||||
);
|
|
||||||
|
|
||||||
PrivateWindows::LanguageCodePage *lpTranslate;
|
PrivateWindows::LanguageCodePage *lpTranslate;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user