New
#1121
Actually, the way I understand it, it's only the factory OEM install media that looks for the OEM marker in the BIOS. The marker has to match a certificate file stored on the OEM media. If they match that PC activates with an OEM generic key.
The key on the sticker is for use with standard install media. It works like an OEM system builders key. Or a retail key for that matter. With one exception. Any time I have ever used one of those OEM-COA keys I had to phone activate the first time it was used. After that it worked just like a retail key and activated online with no issues.
Good, so I'm not going mad then
I haven't tried to fix the one machine this happened on, so I can still investigate this. I signed into another administrator account on the machine and installed ShowKeyPlus there as well. That account also could only run it as administrator.
When run without admin, Reliability History shows one of two different reports for the crash. Examples attached...
@Bree Will you test this version on the wonky install please - just a hunch I have regarding the failure
Failure hits are alarming: For those that may be interested .. this is the what's causing the issues - an automatic GUID is not created - had to create a static GUID but that does not Mutex so multiple instances are alowd - at least the app appears to run
Code:using Microsoft.Win32; using System; using System.Reflection; using System.Runtime.InteropServices; using System.Security.AccessControl; using System.Security.Principal; using System.Threading; using System.Windows; using static ShowKeyPlusWPF.App.Theme; namespace ShowKeyPlusWPF { /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { Theme theme = new Theme(); WindowsTheme newWindowsTheme = theme.GetWindowsTheme(); this.Resources.MergedDictionaries[0].Source = new Uri($"/Themes/" + newWindowsTheme + ".xaml", UriKind.Relative); using (new SingleGlobalInstance(1)) { base.OnStartup(e); } } public class Theme { private const string RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; private const string RegistryValueName = "AppsUseLightTheme"; public enum WindowsTheme { Light, Dark } public WindowsTheme GetWindowsTheme() { using (RegistryKey key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath)) { object registryValueObject = key?.GetValue(RegistryValueName); if (registryValueObject == null) { return WindowsTheme.Light; } int registryValue = (int)registryValueObject; return registryValue > 0 ? WindowsTheme.Light : WindowsTheme.Dark; } } } } class SingleGlobalInstance : IDisposable { public bool _hasHandle = false; Mutex _mutex; private void InitMutex() { string appGuid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value; string mutexId = string.Format("Global\\{{{0}}}", appGuid); _mutex = new Mutex(false, mutexId); var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow); var securitySettings = new MutexSecurity(); securitySettings.AddAccessRule(allowEveryoneRule); _mutex.SetAccessControl(securitySettings); } public SingleGlobalInstance(int timeOut) { InitMutex(); try { if (timeOut < 0) _hasHandle = _mutex.WaitOne(Timeout.Infinite, false); else _hasHandle = _mutex.WaitOne(timeOut, false); if (_hasHandle == false) throw new TimeoutException("Timeout waiting for exclusive access on SingleInstance"); } catch (AbandonedMutexException) { _hasHandle = true; } } public void Dispose() { if (_mutex != null) { if (_hasHandle) _mutex.ReleaseMutex(); _mutex.Close(); } } } }