private static void AddGame(string name, string displayName, string installDir, string registryKey, int sku, int productId) { var f = Path.Combine(Path.Combine(installDir, "Game"), "Bin"); log.Put("Checking Folder: " + f); var folder = new DirectoryInfo(f); if (!folder.Exists) { log.Put("Fail."); log.Put(""); return; } if (folder.GetFiles("TS3CAP.exe").Length > 0) { log.Put("Create-A-Pet-Demo. Continue."); log.Put(""); return; } log.Put("OK."); f = Path.Combine(installDir, datapath); log.Put("Checking Folder: " + f); var folder2 = new DirectoryInfo(f); if (!folder2.Exists) { log.Put("Fail."); log.Put(""); return; } log.Put("OK."); log.Put("Searching Exe files"); var exe = new List<FileInfo>(folder.GetFiles("TS3W.exe")); if (exe.Count == 1) { log.Put("OK. Using TS3W.exe: " + exe[0].Name); UnifiedExe = exe[0].FullName; } exe = new List<FileInfo>(folder.GetFiles("Sims3LauncherW.exe")); if (exe.Count == 1) { log.Put("OK. Using Sims3LauncherW.exe: " + exe[0].Name); UnifiedLauncherExecutable = exe[0].FullName; } var game = new Game(name, installDir, displayName, registryKey == null ? null : registryKey.Substring(19), sku, productId); games.Add(game); log.Put("Game added..."); log.Put(""); }
private static void AddGame(RegistryKey key, string item) { log.Put("Trying to add " + item); try { var subkey = key.OpenSubKey(item); log.Put("Permissions OK."); if (subkey != null) { log.Put("Item found."); string displayName = subkey.GetValue("DisplayName", item).ToString(); log.Put("DisplayName: " + displayName); var installDir = subkey.GetValue("Install Dir"); var sku = subkey.GetValue("SKU", 0); var id = subkey.GetValue("ProductID", 1); if (installDir != null) { log.Put("InstallDir: " + installDir); AddGame(item, displayName, installDir.ToString(), subkey.Name, (int)sku, (int)id); } else { log.Put("No InstallDir. Skipping..."); } } } catch (SecurityException) { var game = new Game(item, string.Empty, item, key.Name.Substring(19) + @"\" + item, 0, 0); games.Add(game); } }