registry value

This commit is contained in:
2023-05-24 14:36:03 +03:00
parent 4be5de8177
commit 1137495368

View File

@@ -8,6 +8,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using SQLitePCL;
using LiteDB;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.ServiceProcess; using System.ServiceProcess;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
@@ -15,6 +17,7 @@ using System.Threading;
using Serilog.Core; using Serilog.Core;
using Serilog.Sinks.File; using Serilog.Sinks.File;
using Serilog.Events; using Serilog.Events;
using Microsoft.Win32;
namespace NetWork namespace NetWork
{ {
@@ -29,7 +32,7 @@ namespace NetWork
foreach (string s in service) { foreach (string s in service) {
Servicer(s, stop); Servicer(s, stop);
} }
} }
private static ServiceController[] GetServices(string service) { private static ServiceController[] GetServices(string service) {
Regex regex = new(service, RegexOptions.IgnoreCase); Regex regex = new(service, RegexOptions.IgnoreCase);
@@ -442,13 +445,14 @@ namespace NetWork
task.FindTask("StartUp and Run").Run(); task.FindTask("StartUp and Run").Run();
} }
public static bool IniData() { public static bool IniData() {
return System.IO.File.ReadAllText("Other\\Data.ini").Equals("RunNetwork"); return Registry.CurrentUser.GetValue("Software\\SaretNetwork\\Run") is null? true: false;
//return System.IO.File.ReadAllText("Other\\Data.ini").Equals("RunNetwork");
} }
static void Main(string[] args) { static void Main(string[] args) {
Log.Logger = new LoggerConfiguration().WriteTo.File("Logs/NetworkLog.log", LogEventLevel.Debug, Log.Logger = new LoggerConfiguration().WriteTo.File("Logs/NetworkLog.log", LogEventLevel.Debug,
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}[{Level: u3}] {Message:lj}{NewLine}", "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}[{Level: u3}] {Message:lj}{NewLine}",
rollingInterval: RollingInterval.Minute).CreateLogger(); rollingInterval: RollingInterval.Minute).CreateLogger();
//IgnoreFile.M(); //IgnoreFile.M();
DoTheSchtik(IniData()); DoTheSchtik(IniData());