From 404bf06e90c8f60025e834675e1662cf1036775f Mon Sep 17 00:00:00 2001 From: tigros Date: Wed, 27 Dec 2023 02:12:07 -0500 Subject: [PATCH] fix for #40 --- whisperer/Form1.cs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/whisperer/Form1.cs b/whisperer/Form1.cs index bf79c31..c08bc88 100644 --- a/whisperer/Form1.cs +++ b/whisperer/Form1.cs @@ -59,6 +59,14 @@ public bool PreFilterMessage(ref Message m) void Form1_Load(object sender, EventArgs e) { + if (!IsAtLeastWindows10()) + { + ShowError(@"Unsupported Windows version, will now exit."); + FormClosing -= new FormClosingEventHandler(Form1_FormClosing); + Application.Exit(); + return; + } + Thread thr = new Thread(initperfcounter); thr.IsBackground = true; thr.Start(); @@ -106,6 +114,18 @@ void Form1_Load(object sender, EventArgs e) button3_Click(null, null); } + bool IsAtLeastWindows10() + { + try + { + string productName = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName", ""); + return productName.Contains("Windows 1") || productName.Contains("Windows 2") || productName.Contains("Windows 3"); + } + catch { } + + return false; + } + void loadfilelist() { string s = readreg("files", ""); @@ -207,10 +227,7 @@ void initperfcounter() } catch (Exception ex) { - if (ex.HResult == -2146233079) - ShowError(@"Unsupported Windows version, will now exit."); - else - ShowError(@"Possibly corrupt perf counters, try C:\Windows\SysWOW64\LODCTR /R from admin cmd prompt, will now exit."); + ShowError(@"Possibly corrupt perf counters, try C:\Windows\SysWOW64\LODCTR /R from elevated cmd prompt, if an error occurs, run it again. Will now exit."); FormClosing -= new FormClosingEventHandler(Form1_FormClosing); Application.Exit(); }