diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index d5a80b5..40cabe4 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "ConfigFormUnit.h" //--------------------------------------------------------------------------- #pragma package(smart_init) @@ -856,6 +857,46 @@ void TConfigForm::SaveSettings() delete ini; } + +void __fastcall TConfigForm::FormActivate(TObject *Sender) +{ + if (!GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version")) + return; + + TRegistry* reg = new TRegistry(KEY_READ); + reg->RootKey = HKEY_CURRENT_USER; + + if(reg->OpenKey("Software\\Wine\\DllOverrides\\", true)) { + + if (!reg->ValueExists("ddraw")) { + + reg->CloseKey(); + + if (Application->MessageBox( + L"cnc-ddraw requires a dll override in winecfg, " + "would you like to add it now?", + L"cnc-ddraw", + MB_YESNO) == IDNO) { + + reg->Free(); + return; + } + + reg->Access = KEY_WRITE; + + if (reg->OpenKey("Software\\Wine\\DllOverrides\\", true)) { + + reg->WriteString("ddraw", "native,builtin"); + reg->CloseKey(); + } + } + else + reg->CloseKey(); + } + + reg->Free(); +} + bool TConfigForm::GetBool(TIniFile *ini, System::UnicodeString key, bool defValue) { auto s = LowerCase(ini->ReadString("ddraw", key, defValue ? "true" : "false")); @@ -954,3 +995,5 @@ void __fastcall TConfigForm::PboxPaint(TObject *Sender) //pbox->Canvas->Rectangle(pbox->ClientRect); } +//--------------------------------------------------------------------------- + diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index 2e453ee..36f3daa 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -2678,6 +2678,7 @@ object ConfigForm: TConfigForm BBBF4CD8CBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCB B88CB18EFF1FA2974C1C31AF16A40000000049454E44AE426082} Position = poDesktopCenter + OnActivate = FormActivate OnCreate = FormCreate TextHeight = 13 object AdvancedPnl: TPanel diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index 8c80133..9bb01ca 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -85,6 +85,7 @@ __published: // Von der IDE verwaltete Komponenten void __fastcall NonexclusiveChkClick(TObject *Sender); void __fastcall PboxPaint(TObject *Sender); void __fastcall LanguageImgClick(TObject *Sender); + void __fastcall FormActivate(TObject *Sender); private: // Benutzer-Deklarationen void SaveSettings(); bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue);