From 80b2df11215c54754d0fb6db712e297d52a1ee11 Mon Sep 17 00:00:00 2001 From: 1kamma Date: Sun, 28 May 2023 06:41:22 +0300 Subject: [PATCH] registry --- NetWork/NetWork.csproj | 5 ++++- NetWork/Program.cs | 4 ++-- NetWork/RegistarRegistry.cs | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 NetWork/RegistarRegistry.cs diff --git a/NetWork/NetWork.csproj b/NetWork/NetWork.csproj index 2f2544c..98dd3fa 100644 --- a/NetWork/NetWork.csproj +++ b/NetWork/NetWork.csproj @@ -7,7 +7,7 @@ NetWork.Program False enable - + true . 7.0 @@ -43,6 +43,8 @@ + + @@ -58,6 +60,7 @@ + diff --git a/NetWork/Program.cs b/NetWork/Program.cs index 5ed1128..996cd8f 100644 --- a/NetWork/Program.cs +++ b/NetWork/Program.cs @@ -445,8 +445,8 @@ namespace NetWork task.FindTask("StartUp and Run").Run(); } public static bool IniData() { - return Registry.CurrentUser.GetValue("Software\\SaretNetwork\\Run") is null? true: false; - //return System.IO.File.ReadAllText("Other\\Data.ini").Equals("RunNetwork"); + var toRunOrNotToRun = Registry.GetValue(@"HKEY_CURRENT_USER\Software\SaretNetwork", "Run", 1); + return toRunOrNotToRun is null? true: toRunOrNotToRun.Equals(1)?true:false; } static void Main(string[] args) { Log.Logger = new LoggerConfiguration().WriteTo.File("Logs/NetworkLog.log", LogEventLevel.Debug, diff --git a/NetWork/RegistarRegistry.cs b/NetWork/RegistarRegistry.cs new file mode 100644 index 0000000..724de66 --- /dev/null +++ b/NetWork/RegistarRegistry.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using Microsoft.Win32; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace NetWork +{ + internal class RegistarRegistry + { + + public static bool IniData() + { + var toRunOrNotToRun = Registry.GetValue(@"HKEY_CURRENT_USER\Software\SaretNetwork", "Run", 1); + return toRunOrNotToRun is null ? true : toRunOrNotToRun.Equals(1) ? true : false; + } + } + internal class NetworkInterface + { + //public + } + internal class ListOfPrograms + { + public string[] ProgramName { get; private set; } + public string[] ProgramPath { get; private set; } + 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(); + } + } +}