NOISSUE Better Windows version detection and user agent
This commit is contained in:
parent
121e2fd46c
commit
486d653586
@ -20,8 +20,12 @@
|
|||||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||||
<!--The ID below indicates app support for Windows 7 -->
|
<!--The ID below indicates app support for Windows 7 -->
|
||||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||||
<!--The ID below indicates app support for Windows Developer Preview / Windows 8 -->
|
<!--The ID below indicates app support for Windows 8 -->
|
||||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||||
|
<!--The ID below indicates app support for Windows 8.1 -->
|
||||||
|
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||||
|
<!--The ID below indicates app support for Windows 10 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||||
</application>
|
</application>
|
||||||
</compatibility>
|
</compatibility>
|
||||||
</assembly>
|
</assembly>
|
@ -106,10 +106,9 @@ QString GAnalyticsWorker::getScreenResolution()
|
|||||||
*/
|
*/
|
||||||
QString GAnalyticsWorker::getUserAgent()
|
QString GAnalyticsWorker::getUserAgent()
|
||||||
{
|
{
|
||||||
QString locale = QLocale::system().name();
|
|
||||||
QString system = Sys::getSystemInfo();
|
QString system = Sys::getSystemInfo();
|
||||||
|
|
||||||
return QString("%1/%2 (%3; %4) GAnalytics/1.0 (Qt/%5)").arg(m_appName).arg(m_appVersion).arg(system).arg(locale).arg(QT_VERSION_STR);
|
return QString("%1/%2 (%3)").arg(m_appName).arg(m_appVersion).arg(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,55 +1,50 @@
|
|||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
// FIXME: replace with our version...
|
#include <windows.h>
|
||||||
|
|
||||||
QString Sys::getSystemInfo()
|
QString Sys::getSystemInfo()
|
||||||
{
|
{
|
||||||
QSysInfo::WinVersion version = QSysInfo::windowsVersion();
|
static QString cached;
|
||||||
QString os("Windows; ");
|
if(!cached.isNull())
|
||||||
switch (version)
|
|
||||||
{
|
{
|
||||||
case QSysInfo::WV_95:
|
return cached;
|
||||||
os += "Win 95";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_98:
|
|
||||||
os += "Win 98";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_Me:
|
|
||||||
os += "Win ME";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_NT:
|
|
||||||
os += "Win NT";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_2000:
|
|
||||||
os += "Win 2000";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_2003:
|
|
||||||
os += "Win Server 2003";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_VISTA:
|
|
||||||
os += "Win Vista";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_WINDOWS7:
|
|
||||||
os += "Win 7";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_WINDOWS8:
|
|
||||||
os += "Win 8";
|
|
||||||
break;
|
|
||||||
case QSysInfo::WV_WINDOWS8_1:
|
|
||||||
os += "Win 8.1";
|
|
||||||
break;
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
|
|
||||||
case QSysInfo::WV_WINDOWS10:
|
|
||||||
os += "Win 10";
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
os = "Windows; unknown";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return os;
|
else
|
||||||
}
|
{
|
||||||
|
// We support only Windows NT (XP and up) - everything else is not interesting.
|
||||||
|
OSVERSIONINFO osvi;
|
||||||
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||||
|
GetVersionExW(&osvi);
|
||||||
|
QString os = QString("Windows NT %1.%2").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion);
|
||||||
|
|
||||||
#include <windows.h>
|
#if defined(_WIN64)
|
||||||
|
// 64-bit programs run only on Win64
|
||||||
|
os.append("; Win64");
|
||||||
|
// determine CPU type
|
||||||
|
SYSTEM_INFO info;
|
||||||
|
ZeroMemory(&info, sizeof(SYSTEM_INFO));
|
||||||
|
GetNativeSystemInfo(&info);
|
||||||
|
auto arch = info.wProcessorArchitecture;
|
||||||
|
if(arch == PROCESSOR_ARCHITECTURE_AMD64)
|
||||||
|
{
|
||||||
|
os.append("; x64");
|
||||||
|
}
|
||||||
|
else if (arch == PROCESSOR_ARCHITECTURE_IA64)
|
||||||
|
{
|
||||||
|
os.append("; IA64");
|
||||||
|
}
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
// 32-bit programs run on both 32-bit and 64-bit Windows
|
||||||
|
// so must sniff
|
||||||
|
BOOL f64 = false;
|
||||||
|
if(IsWow64Process(GetCurrentProcess(), &f64) && f64)
|
||||||
|
{
|
||||||
|
os.append("; WOW64");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Sys::getSystemRam()
|
uint64_t Sys::getSystemRam()
|
||||||
{
|
{
|
||||||
@ -63,10 +58,8 @@ uint64_t Sys::getSystemRam()
|
|||||||
bool Sys::isSystem64bit()
|
bool Sys::isSystem64bit()
|
||||||
{
|
{
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
return true; // 64-bit programs run only on Win64
|
return true;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
// 32-bit programs run on both 32-bit and 64-bit Windows
|
|
||||||
// so must sniff
|
|
||||||
BOOL f64 = false;
|
BOOL f64 = false;
|
||||||
return IsWow64Process(GetCurrentProcess(), &f64) && f64;
|
return IsWow64Process(GetCurrentProcess(), &f64) && f64;
|
||||||
#else
|
#else
|
||||||
@ -78,6 +71,7 @@ bool Sys::isSystem64bit()
|
|||||||
bool Sys::isCPU64bit()
|
bool Sys::isCPU64bit()
|
||||||
{
|
{
|
||||||
SYSTEM_INFO info;
|
SYSTEM_INFO info;
|
||||||
|
ZeroMemory(&info, sizeof(SYSTEM_INFO));
|
||||||
GetNativeSystemInfo(&info);
|
GetNativeSystemInfo(&info);
|
||||||
auto arch = info.wProcessorArchitecture;
|
auto arch = info.wProcessorArchitecture;
|
||||||
return arch == PROCESSOR_ARCHITECTURE_AMD64 || arch == PROCESSOR_ARCHITECTURE_IA64;
|
return arch == PROCESSOR_ARCHITECTURE_AMD64 || arch == PROCESSOR_ARCHITECTURE_IA64;
|
||||||
|
Loading…
Reference in New Issue
Block a user