From e15b65add34b28e9c90ec816b018c29cc24d2557 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 27 Jul 2017 14:10:54 +0200 Subject: Detecting BCS version number --- Aktywator/MainForm.cs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Aktywator/MainForm.cs b/Aktywator/MainForm.cs index d8fb6c0..8d8fb89 100644 --- a/Aktywator/MainForm.cs +++ b/Aktywator/MainForm.cs @@ -6,6 +6,7 @@ using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; +using Microsoft.Win32; namespace Aktywator { @@ -17,6 +18,8 @@ namespace Aktywator private Bws bws; private Tournament tournament; + private Version BCSVersion; + public MainForm() { InitializeComponent(); @@ -32,6 +35,17 @@ namespace Aktywator status2.Text = "Wersja " + this.version; status3.Text = "Data: " + this.date; + string detectedVersion = detectBCSVersion(); + if (detectedVersion != null) + { + lDetectedVersion.Text = detectedVersion; + BCSVersion = new Version(detectedVersion); + } + else + { + lDetectedVersion.Text = "nie wykryto"; + } + string filename; string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) @@ -56,6 +70,45 @@ namespace Aktywator this.WindowState = FormWindowState.Normal; } + private string detectBCSVersion() + { + RegistryKey[] keys = + { + Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"), + Registry.CurrentUser.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"), + Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"), + Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall") + }; + foreach (RegistryKey key in keys) + { + if (key != null) + { + foreach (var subKey in key.GetSubKeyNames()) + { + RegistryKey appKey = key.OpenSubKey(subKey); + if (appKey != null) + { + foreach (var value in appKey.GetValueNames()) + { + string keyValue = Convert.ToString(appKey.GetValue("Publisher")); + if (!keyValue.Equals("Bridge Systems BV", StringComparison.OrdinalIgnoreCase)) + continue; + + string productName = Convert.ToString(appKey.GetValue("DisplayName")); + if (!productName.Equals("Bridgemate Control Software", StringComparison.OrdinalIgnoreCase) + && !productName.Equals("Bridgemate Pro Control", StringComparison.OrdinalIgnoreCase)) + continue; + + string version = Convert.ToString(appKey.GetValue("DisplayVersion")); + return version; + } + } + } + } + } + return null; + } + private void bLaunch_Click(object sender, EventArgs e) { if (trySave()) -- cgit v1.2.3