1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-28 07:52:28 +01:00

disable GameUX on windows 7

This commit is contained in:
FunkyFr3sh 2023-09-07 19:54:19 +02:00
parent 43fd64463b
commit f3c57b477e
2 changed files with 49 additions and 0 deletions

View File

@ -1127,6 +1127,12 @@ void TConfigForm::SaveSettings()
} }
void __fastcall TConfigForm::FormActivate(TObject *Sender) void __fastcall TConfigForm::FormActivate(TObject *Sender)
{
DisableGameUX();
AddDllOverride();
}
void TConfigForm::AddDllOverride()
{ {
/* Detect wine (Linux/macOS) and create the needed dll override */ /* Detect wine (Linux/macOS) and create the needed dll override */
if (!GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version")) if (!GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version"))
@ -1166,6 +1172,47 @@ void __fastcall TConfigForm::FormActivate(TObject *Sender)
reg->Free(); 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) void __fastcall TConfigForm::HotkeyEdtKeyDown(TObject *Sender, WORD &Key, TShiftState Shift)
{ {
TEdit *edit = static_cast<TEdit*>(Sender); TEdit *edit = static_cast<TEdit*>(Sender);

View File

@ -121,6 +121,8 @@ private: // Benutzer-Deklarationen
void ApplyTranslation(TIniFile *ini); void ApplyTranslation(TIniFile *ini);
System::UnicodeString GetKeyText(WORD key); System::UnicodeString GetKeyText(WORD key);
WORD GetKeyCode(System::UnicodeString key); WORD GetKeyCode(System::UnicodeString key);
void DisableGameUX();
void AddDllOverride();
public: // Benutzer-Deklarationen public: // Benutzer-Deklarationen
__fastcall TConfigForm(TComponent* Owner); __fastcall TConfigForm(TComponent* Owner);
}; };