summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-07-27 14:10:54 +0200
committeremkael <emkael@tlen.pl>2017-07-27 14:10:54 +0200
commite15b65add34b28e9c90ec816b018c29cc24d2557 (patch)
tree38b0d6bdb1a928c84cfff06e29cfaacf47df7b4a
parent7f69103e6d2c17335e2b8092f44dfc2315d2a2ee (diff)
Detecting BCS version number
-rw-r--r--Aktywator/MainForm.cs53
1 files changed, 53 insertions, 0 deletions
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())