public void EnableTweak() { var unlockerDir = Path.Combine("GameFiles", "Tweaks", "Unlocker"); if (!Directory.Exists(unlockerDir)) { throw new Exception("Could not find unlocker in GameFiles!"); } //TODO: Сделать более качественную проверку на наличие файлов в GameFiles var gamePath = PathFinder.GamePath; var targetDir = Path.Combine(gamePath, "Unlocker"); if (!Directory.Exists(targetDir)) { Directory.CreateDirectory(targetDir); } ExplorerExtensions.ClearFlagsInDirFiles(targetDir); var unlockerFiles = Directory.GetFiles(unlockerDir); foreach (var unlockerFile in unlockerFiles) { File.Copy(unlockerFile, Path.Combine(targetDir, Path.GetFileName(unlockerFile)), true); } string dowCdKey = "3697-5fd2-5a76-0e44"; string waCdKey = "57a4-fae0-7611-1504-fa90"; string dcCdKey = "8c34-5670-91a4-c2f2-bfca"; string ssCdKey = "BEEF-B00B-BABE-CAFE-80F1"; var thqKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).CreateSubKey("Software\\THQ"); var dowReg = thqKey.CreateSubKey("Dawn Of War"); dowReg.SetValue("CDKEY", dowCdKey); dowReg.SetValue("CDKEY_WXP", waCdKey); dowReg.SetValue("dawnofwar_ver", "1.51"); dowReg.SetValue("installlocation", gamePath + "\\Unlocker\\"); var dcReg = thqKey.CreateSubKey("Dawn Of War - Dark Crusade"); dcReg.SetValue("CDKEY", dcCdKey); dcReg.SetValue("w40kcdkey", dowCdKey); dcReg.SetValue("wxpcdkey", waCdKey); dcReg.SetValue("installlocation", gamePath + "\\Unlocker\\"); var ssReg = thqKey.CreateSubKey("Dawn Of War - Soulstorm"); ssReg.SetValue("CDKEY", ssCdKey); ssReg.SetValue("w40kcdkey", dowCdKey); ssReg.SetValue("wxpcdkey", waCdKey); ssReg.SetValue("dxp2cdkey", dcCdKey); }
public void DisableTweak() { var gamePath = PathFinder.GamePath; var targetDir = Path.Combine(gamePath, "Unlocker"); if (Directory.Exists(targetDir)) { ExplorerExtensions.ClearFlagsInDirFiles(targetDir); Directory.Delete(targetDir, true); } var softwareKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("Software", true); if (softwareKey.OpenSubKey("THQ") != null) { softwareKey.DeleteSubKeyTree("THQ"); } }