From 04140081cef8c2cb05d743fd8a168049ab9a36d2 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 18 Jul 2018 00:56:05 -0500 Subject: [PATCH] Fixed problem when registry key does not exist --- DS4Windows/DS4Control/ControlService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/DS4Windows/DS4Control/ControlService.cs b/DS4Windows/DS4Control/ControlService.cs index 8c6d7fc..2fddee8 100644 --- a/DS4Windows/DS4Control/ControlService.cs +++ b/DS4Windows/DS4Control/ControlService.cs @@ -87,7 +87,16 @@ namespace DS4Windows public void ScanPurgeHidGuard() { RegistryKey tempkey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist"); - string[] subkeys = tempkey.GetSubKeyNames(); + string[] subkeys = null; + if (tempkey != null) + { + subkeys = tempkey.GetSubKeyNames(); + } + else + { + subkeys = new string[0]; + } + bool processExists = false; for (int ind = 0, arlen = subkeys.Length; ind < arlen; ind++) {