From 3575291119df80716bd4296e8d02bb544eec0e09 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 12 May 2022 08:52:40 +0800 Subject: [PATCH] add multiple program auto run --- v2rayN/v2rayN/Tool/Utils.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/v2rayN/v2rayN/Tool/Utils.cs b/v2rayN/v2rayN/Tool/Utils.cs index 76922378..afe8d8ff 100644 --- a/v2rayN/v2rayN/Tool/Utils.cs +++ b/v2rayN/v2rayN/Tool/Utils.cs @@ -23,6 +23,7 @@ using Newtonsoft.Json.Linq; using System.Web; using log4net; using System.Linq; +using System.Security.Cryptography; namespace v2rayN { @@ -397,6 +398,20 @@ namespace v2rayN { return HttpUtility.UrlDecode(url); } + + public static string GetMD5(string str) + { + var md5 = MD5.Create(); + byte[] byteOld = Encoding.UTF8.GetBytes(str); + byte[] byteNew = md5.ComputeHash(byteOld); + StringBuilder sb = new StringBuilder(); + foreach (byte b in byteNew) + { + sb.Append(b.ToString("x2")); + } + return sb.ToString(); + } + #endregion @@ -529,7 +544,13 @@ namespace v2rayN #region 开机自动启动 - private static string autoRunName = "v2rayNAutoRun"; + private static string autoRunName + { + get + { + return $"v2rayNAutoRun_{GetMD5(StartupPath())}"; + } + } private static string autoRunRegPath { get