commit
ef267ef186
2 changed files with 8 additions and 8 deletions
|
@ -77,7 +77,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
foreach (var cursor in cursors.Where(c => !string.IsNullOrWhiteSpace(c)))
|
foreach (var cursor in cursors.Where(c => !string.IsNullOrWhiteSpace(c)))
|
||||||
{
|
{
|
||||||
success &= registry.TryRead(RegistryValue.UserHive.Cursors_Key, cursor, out var value);
|
success &= registry.TryRead(RegistryValue.UserHive.Cursors_Key, cursor, out var value);
|
||||||
success &= value == default || !(value is string) || (value is string path && (string.IsNullOrWhiteSpace(path) || IsValidCursorPath(path)));
|
success &= !(value is string) || (value is string path && (string.IsNullOrWhiteSpace(path) || IsValidCursorPath(path)));
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
|
|
||||||
if (registry.TryRead(RegistryValue.MachineHive.EaseOfAccess_Key, RegistryValue.MachineHive.EaseOfAccess_Name, out var value))
|
if (registry.TryRead(RegistryValue.MachineHive.EaseOfAccess_Key, RegistryValue.MachineHive.EaseOfAccess_Name, out var value))
|
||||||
{
|
{
|
||||||
if (value == default || (value is string s && string.IsNullOrWhiteSpace(s)))
|
if (value is string s && string.IsNullOrWhiteSpace(s))
|
||||||
{
|
{
|
||||||
success = true;
|
success = true;
|
||||||
logger.Info("Ease of access configuration successfully verified.");
|
logger.Info("Ease of access configuration successfully verified.");
|
||||||
|
@ -135,7 +135,8 @@ namespace SafeExamBrowser.Runtime.Operations
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Error("Failed to verify ease of access configuration!");
|
success = true;
|
||||||
|
logger.Info("Ease of access configuration successfully verified (value does not exist).");
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|
|
@ -73,21 +73,20 @@ namespace SafeExamBrowser.SystemComponents.Registry
|
||||||
|
|
||||||
public bool TryRead(string key, string name, out object value)
|
public bool TryRead(string key, string name, out object value)
|
||||||
{
|
{
|
||||||
var success = false;
|
var defaultValue = new object();
|
||||||
|
|
||||||
value = default;
|
value = default;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
value = Microsoft.Win32.Registry.GetValue(key, name, default);
|
value = Microsoft.Win32.Registry.GetValue(key, name, defaultValue);
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.Error($"Failed to read value '{name}' from registry key '{key}'!", e);
|
logger.Error($"Failed to read value '{name}' from registry key '{key}'!", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return value != default && !ReferenceEquals(value, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetNames(string keyName, out IEnumerable<string> names)
|
public bool TryGetNames(string keyName, out IEnumerable<string> names)
|
||||||
|
|
Loading…
Reference in a new issue