From 121dfa381d3110fa80b54f92b9647835f25d3487 Mon Sep 17 00:00:00 2001 From: 1kamma Date: Tue, 30 May 2023 00:23:07 +0300 Subject: [PATCH] track --- NetWork/RegistarRegistry.cs | 40 ++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/NetWork/RegistarRegistry.cs b/NetWork/RegistarRegistry.cs index 724de66..4a7e1b1 100644 --- a/NetWork/RegistarRegistry.cs +++ b/NetWork/RegistarRegistry.cs @@ -20,7 +20,16 @@ namespace NetWork } internal class NetworkInterface { - //public + public string Name { get; set; } + public ListOfPrograms ListOfProgramsToStart { get; set; } + public ListOfPrograms ListOfProgramsToStop { get; set; } + public string[] ServicesToStart { get; set; } + public string[] ServicesToStop { get;set; } + public bool Mute { get; set; }=true; + public NetworkInterface(string name, string url) + { + Name = name; + } } internal class ListOfPrograms { @@ -29,14 +38,27 @@ namespace NetWork public ListOfPrograms(string url) { WebClient webClient = new(); string[] data = Regex.Split(Regex.Replace(webClient.DownloadString(url),@"[\{\}]",""),","); - //ProgramName = new string[data.Length]; - //ProgramPath = new string[data.Length]; - //for(int i = 0; i < data.Length; i++) - //{ - // ProgramName[i] = Regex. - //} - string d = Regex.Replace(webClient.DownloadString(url), @"[\{\}]", ""); - ProgramName = Regex.Matches(d,@"(?<=\"")\w+(?=\"":)").Select(x => x.Value).ToArray(); + ProgramName = new string[data.Length]; + ProgramPath = new string[data.Length]; + for(int i = 0; i < data.Length; i++) + { + ProgramName[i] = Regex.Match(data[i], @"(?<="").+(?="":)").Value; + ProgramPath[i] = Regex.Match(data[i], @"(?<=:\s?"")[^""]+").Value; + } + //string d = Regex.Replace(webClient.DownloadString(url), @"[\{\}]", ""); + //ProgramName = Regex.Matches(d,@"(?<=\"")\w+(?=\"":)").Select(x => x.Value).ToArray(); + } + public ListOfPrograms(string registryHive, string registryName) + { + string location = Regex.IsMatch(registryHive, @"HKEY_") ? Regex.Replace(registryHive, @"^[^\\]+", "")[1..] : registryHive; + RegistryKey key = Registry.CurrentUser.OpenSubKey($"{location}\\{registryName}") ; + ProgramName = key.GetValueNames(); + ProgramPath = new string[ProgramName.Length]; + for (int i = 0; i < ProgramName.Length; i++) + { + ProgramPath[i] = Registry.GetValue($"HKEY_CURRENT_USER\\{location}\\{registryName}", ProgramName[i], "").ToString(); + } } } + }