Merge pull request #1817 from openscad/wininfo_fix_2016

Wininfo fix 2016 for issue #1800
This commit is contained in:
Marius Kintel 2016-10-07 13:03:49 +02:00 committed by GitHub
commit 836f9ff8de
5 changed files with 45 additions and 60 deletions

View file

@ -4,6 +4,9 @@
# include <winver.h>
# endif
#include "winuser.h"
1 RT_MANIFEST "scripts/winmanifest.xml"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0
PRODUCTVERSION 0,0,0,0

View file

@ -43,7 +43,7 @@ fi
if [ ! $MXEDIR ]; then
if [ "`echo $* | grep 64 `" ]; then
MXEDIR=$BASEDIR/mxe-w64
MXEDIR=$BASEDIR/mxe
else
MXEDIR=$BASEDIR/mxe
fi

28
scripts/winmanifest.xml Normal file
View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<description>OpenSCAD</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>

View file

@ -124,79 +124,34 @@ static BOOL IsWow64()
std::string PlatformUtils::sysinfo(bool extended)
{
std::string result;
OSVERSIONINFOEX osinfo;
osinfo.dwOSVersionInfoSize = sizeof(osinfo);
if (GetVersionExEx(&osinfo) == 0) {
result += "Unknown Windows";
result += "Unknown Windows(TM)";
} else {
unsigned int version = osinfo.dwMajorVersion * 1000 + osinfo.dwMinorVersion;
if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
switch (version) {
case 5000:
result += "Windows 2000";
break;
case 5001:
result += "Windows XP";
break;
case 5002:
result += "Windows Server 2003";
break;
case 6000:
result += (osinfo.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008");
break;
case 6001:
result += (osinfo.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2");
break;
case 6002:
result += (osinfo.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 2012");
break;
case 6003:
// For applications that have been manifested for Windows 8.1.
result += (osinfo.wProductType == VER_NT_WORKSTATION ? "Windows 8.1" : "Windows Server 2012 R2");
break;
default:
result += "Unknown Windows";
break;
}
if (osinfo.wServicePackMajor > 0) {
boost::format fmtServicePack;
if (osinfo.wServicePackMinor == 0) {
fmtServicePack = boost::format(" SP%d");
fmtServicePack % osinfo.wServicePackMajor;
} else {
fmtServicePack = boost::format(" SP%d.%d");
fmtServicePack % osinfo.wServicePackMajor % osinfo.wServicePackMinor;
}
result += fmtServicePack.str();
}
boost::format fmt(" (v%d.%d.%d.%d)");
fmt % osinfo.dwMajorVersion % osinfo.dwMinorVersion % osinfo.wServicePackMajor % osinfo.wServicePackMinor;
boost::format fmt("Windows(TM) %d.%d SP %d.%d NTW %i MSDN 724833");
fmt % osinfo.dwMajorVersion % osinfo.dwMinorVersion
% osinfo.wServicePackMajor % osinfo.wServicePackMinor
% (osinfo.wProductType == VER_NT_WORKSTATION);
result += fmt.str();
} else {
boost::format fmt("Unknown Windows (dwPlatformId = %d, dwMajorVersion = %d, dwMinorVersion = %d");
fmt % osinfo.dwPlatformId % osinfo.dwMajorVersion % osinfo.dwMinorVersion;
result += fmt.str();
}
}
SYSTEM_INFO systeminfo;
bool isWow64 = IsWow64();
if (isWow64) {
GetNativeSystemInfo(&systeminfo);
} else {
GetSystemInfo(&systeminfo);
GetSystemInfo(&systeminfo);
}
if (extended) {
int numcpu = systeminfo.dwNumberOfProcessors;
boost::format fmt(" %d CPU%s%s");
fmt % numcpu % (numcpu > 1 ? "s" : "") % (isWow64 ? " WOW64" : "");
result += fmt.str();
MEMORYSTATUSEX memoryinfo;
memoryinfo.dwLength = sizeof(memoryinfo);
if (GlobalMemoryStatusEx(&memoryinfo) != 0) {
@ -204,7 +159,7 @@ std::string PlatformUtils::sysinfo(bool extended)
result += PlatformUtils::toMemorySizeString(memoryinfo.ullTotalPhys, 2);
result += " RAM";
}
}
}
return result;
}

View file

@ -45,8 +45,7 @@ namespace PlatformUtils {
* OS type is reported based on what platform the application was
* built for.
*
* Extended sysinfo will return more info, like CPUs and RAM
*
* Extended sysinfo will return more info, like CPUs and RAM
* @return system information.
*/
std::string sysinfo(bool extended = true);