diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 1e5bdac..0a82b95 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -1127,6 +1127,12 @@ void TConfigForm::SaveSettings() } void __fastcall TConfigForm::FormActivate(TObject *Sender) +{ + DisableGameUX(); + AddDllOverride(); +} + +void TConfigForm::AddDllOverride() { /* Detect wine (Linux/macOS) and create the needed dll override */ if (!GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version")) @@ -1166,6 +1172,47 @@ void __fastcall TConfigForm::FormActivate(TObject *Sender) reg->Free(); } +void TConfigForm::DisableGameUX() +{ + /* Prevent bug where some games don't start properly and run in the background */ + if (!(TOSVersion::Major == 6 && TOSVersion::Minor == 1)) + return; + + TRegistry* reg = new TRegistry(KEY_READ); + reg->RootKey = HKEY_CLASSES_ROOT; + + if (reg->OpenKey( + "Local Settings\\Software\\Microsoft\\Windows\\GameUX\\ServiceLocation\\", + false)) { + + if (reg->ValueExists("Games") && + reg->ReadString("Games") != "127.0.0.1" && + LowerCase(reg->ReadString("Games")) != "localhost") { + + reg->CloseKey(); + + reg->Access = KEY_WRITE; + + if (reg->OpenKey( + "Local Settings\\Software\\Microsoft\\Windows\\GameUX\\ServiceLocation\\", + false)) { + + try { + reg->WriteString("Games", "127.0.0.1"); + } catch (...) { + /* maybe restart with admin rights here? */ + } + + reg->CloseKey(); + } + } + else + reg->CloseKey(); + } + + reg->Free(); +} + void __fastcall TConfigForm::HotkeyEdtKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { TEdit *edit = static_cast(Sender); diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index 2e16295..eca5be1 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -121,6 +121,8 @@ private: // Benutzer-Deklarationen void ApplyTranslation(TIniFile *ini); System::UnicodeString GetKeyText(WORD key); WORD GetKeyCode(System::UnicodeString key); + void DisableGameUX(); + void AddDllOverride(); public: // Benutzer-Deklarationen __fastcall TConfigForm(TComponent* Owner); };