add workaround for registry read error

This commit is contained in:
fyr77 2021-05-02 16:16:03 +02:00
parent a42641fdce
commit babacb68dd
2 changed files with 21 additions and 3 deletions

View file

@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Linq; using System.Linq;
namespace EnvyUpdate namespace EnvyUpdate

View file

@ -387,11 +387,28 @@ namespace EnvyUpdate
RegistryKey nvlddmkm = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\services\nvlddmkm", true); RegistryKey nvlddmkm = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\services\nvlddmkm", true);
return nvlddmkm.GetValueNames().Contains("DCHUVen"); return nvlddmkm.GetValueNames().Contains("DCHUVen");
} }
catch (NullReferenceException) catch (Exception ex)
{
if (ex.InnerException is NullReferenceException)
{ {
// Assume no DCH driver is installed if key is not found. // Assume no DCH driver is installed if key is not found.
return false; return false;
} }
else if (ex.InnerException is System.Security.SecurityException)
{
//Registry reading error. Check for existance of file nvsvs.dll instead.
if (System.IO.File.Exists(Path.Combine(Environment.SystemDirectory, "nvsvs.dll")))
return true;
else
return false;
}
else
{
MessageBox.Show("An error has occured. Please report this on GitHub.\nError:" + ex.Message);
Environment.Exit(20);
return false;
}
}
} }
public static int GetDTCID() public static int GetDTCID()
{ {