mirror of
https://github.com/isledecomp/LEGOIslandRebuilder.git
synced 2024-11-27 01:25:36 -05:00
force compatibility modes on appropriate operating systems
This commit is contained in:
parent
e04a53fbe4
commit
0f12daa5ac
2 changed files with 52 additions and 13 deletions
|
@ -2,6 +2,20 @@
|
||||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||||
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="com.itsmattkc.Rebuilder" type="win32" />
|
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="com.itsmattkc.Rebuilder" type="win32" />
|
||||||
<description>LEGO Island modding tool and launcher.</description>
|
<description>LEGO Island modding tool and launcher.</description>
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- Windows 10 and Windows 11 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||||
|
<!-- Windows 8.1 -->
|
||||||
|
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||||
|
<!-- Windows 8 -->
|
||||||
|
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||||
|
<!-- Windows 7 -->
|
||||||
|
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||||
|
<!-- Windows Vista -->
|
||||||
|
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
<dependency>
|
<dependency>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
|
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
|
||||||
|
|
|
@ -2,9 +2,12 @@
|
||||||
|
|
||||||
#include <COMMDLG.H>
|
#include <COMMDLG.H>
|
||||||
#include <SHLWAPI.H>
|
#include <SHLWAPI.H>
|
||||||
|
#include <STRING>
|
||||||
|
|
||||||
|
#include "../cmn/path.h"
|
||||||
#include "../res/resource.h"
|
#include "../res/resource.h"
|
||||||
|
|
||||||
|
typedef DWORD (WINAPI *GetLongPathName_t)(LPCSTR lpszShortPath, LPSTR lpszLongPath, DWORD cchBuffer);
|
||||||
HANDLE Launcher::Launch(HWND parent)
|
HANDLE Launcher::Launch(HWND parent)
|
||||||
{
|
{
|
||||||
// Find the installation
|
// Find the installation
|
||||||
|
@ -15,22 +18,44 @@ HANDLE Launcher::Launch(HWND parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set compatibility flags
|
// Set compatibility flags
|
||||||
HKEY hKey;
|
OSVERSIONINFO info;
|
||||||
LPCTSTR str = TEXT("~ HIGHDPIAWARE 16BITCOLOR DWM8And16BitMitigation");
|
ZeroMemory(&info, sizeof(OSVERSIONINFO));
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) {
|
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
// Often we seem to get an 8.3 path which is not valid here, so resolve the full path now
|
GetVersionEx(&info);
|
||||||
TCHAR full_path[MAX_PATH];
|
|
||||||
GetLongPathName(filename, full_path, MAX_PATH);
|
|
||||||
MessageBoxA(0,full_path,0,0);
|
|
||||||
|
|
||||||
LONG ret = RegSetValueEx(hKey, full_path, 0, REG_SZ, (const BYTE *) str, strlen(str)+1);
|
if (info.dwMajorVersion >= 5) {
|
||||||
if (ret != ERROR_SUCCESS) {
|
HKEY hKey;
|
||||||
char buf[100];
|
std::string compat = "~ HIGHDPIAWARE";
|
||||||
sprintf(buf, "Failed to set compatibility flags: 0x%x. This may cause issues on newer versions of Windows.", ret);
|
|
||||||
MessageBox(parent, buf, 0, 0);
|
TCHAR configPath[MAX_PATH];
|
||||||
|
GetConfigFilename(configPath);
|
||||||
|
|
||||||
|
// If windowed, force a bit depth
|
||||||
|
if (!GetPrivateProfileInt(appName, "FullScreen", true, configPath)) {
|
||||||
|
if (info.dwMajorVersion >= 8) {
|
||||||
|
compat += " 16BITCOLOR";
|
||||||
|
} else {
|
||||||
|
compat += " 256COLOR";
|
||||||
|
}
|
||||||
|
compat += " DWM8And16BitMitigation";
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) {
|
||||||
|
// Often we seem to get an 8.3 path which is not valid here, so resolve the full path now
|
||||||
|
TCHAR full_path[MAX_PATH];
|
||||||
|
GetLongPathName_t getLongPathName = (GetLongPathName_t) GetProcAddress(GetModuleHandle("KERNEL32.DLL"), "GetLongPathNameA");
|
||||||
|
getLongPathName(filename, full_path, MAX_PATH);
|
||||||
|
MessageBoxA(0,full_path,0,0);
|
||||||
|
|
||||||
|
LONG ret = RegSetValueEx(hKey, full_path, 0, REG_SZ, (const BYTE *) &compat[0], compat.size()+1);
|
||||||
|
if (ret != ERROR_SUCCESS) {
|
||||||
|
char buf[100];
|
||||||
|
sprintf(buf, "Failed to set compatibility flags: 0x%x. This may cause issues on newer versions of Windows.", ret);
|
||||||
|
MessageBox(parent, buf, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue