예제 #1
0
        public List <string> GetDevices()
        {
            object value = registryModifierService.GetValue(PARAMETERS, AFFECTED_DEVICES);

            if (value is string[])
            {
                return(new List <string>(value as string[]));
            }
            return(new List <string>());
        }
예제 #2
0
        private string GetHardwareIdFromRegistryWithHidMatch(Match match)
        {
            string path = $"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\{match.Groups[2].Value}";

            if (registryModifierService.KeyExists(path))
            {
                foreach (string subkey in registryModifierService.GetSubKeyNames(path))
                {
                    string parentIdPrefix = registryModifierService.GetValue <string>($"{path}\\{subkey}", "ParentIdPrefix");
                    if (parentIdPrefix == null || !match.Groups[3].Value.StartsWith(parentIdPrefix))
                    {
                        continue;
                    }
                    object registryHardwareIds = registryModifierService.GetValue($"{path}\\{subkey}", "HardwareID");
                    if (registryHardwareIds is string[])
                    {
                        return((registryHardwareIds as string[]).Select(id => id.Replace("USB\\", "HID\\")).FirstOrDefault());
                    }
                }
            }
            return(null);
        }