diff --git a/PCRobot/PCRobot.csproj b/PCRobot/PCRobot.csproj
index 9eaee61..48b42fe 100644
--- a/PCRobot/PCRobot.csproj
+++ b/PCRobot/PCRobot.csproj
@@ -42,7 +42,7 @@
tencent_qqpim_72px_1127550_easyicon.net.ico
- Properties\app.manifest
+ app.manifest
@@ -316,6 +316,7 @@
WechatUpdate.cs
+
diff --git a/PCRobot/PCRobotForm.cs b/PCRobot/PCRobotForm.cs
index cdf0b3d..1eb4f33 100644
--- a/PCRobot/PCRobotForm.cs
+++ b/PCRobot/PCRobotForm.cs
@@ -39,6 +39,16 @@ namespace PCRobot
private void PCRobotForm_Load(object sender, EventArgs e)
{
+ try
+ {
+ WeChatActivateHelper.Set_Hosts("dldir1v6.qq.com", "127.0.0.1");
+ WeChatActivateHelper.Set_Hosts("dldir1.qq.com", "127.0.0.1");
+ LogHelper.GetSingleObj().Info("屏蔽", "屏蔽微信自动更新成功");
+ }
+ catch (Exception exception)
+ {
+ LogHelper.GetSingleObj().Info("屏蔽", "屏蔽微信自动更新异常");
+ }
try
{
diff --git a/PCRobot/Utils/WeChatActivateHelper.cs b/PCRobot/Utils/WeChatActivateHelper.cs
index 0ca5d81..cdb28e2 100644
--- a/PCRobot/Utils/WeChatActivateHelper.cs
+++ b/PCRobot/Utils/WeChatActivateHelper.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
+using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -171,6 +172,8 @@ namespace WechatHelper
}
}
+
+
///
/// 关闭窗口
///
@@ -298,6 +301,44 @@ namespace WechatHelper
{
_mouseHeartbeatTime = DateTime.Now;
}
+
+ public static void Set_Hosts(string domain, string ip)
+ {
+ string path = System.Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\drivers\\etc\\hosts";
+ if (File.GetAttributes(path) == (FileAttributes.ReadOnly | FileAttributes.Archive))
+ {
+ File.SetAttributes(path, FileAttributes.Archive);
+ }
+
+
+ string[] hosts = File.ReadAllLines(path);
+ List list = hosts.ToList();
+ string temp = hosts.ToList().FirstOrDefault(x => x.Contains(domain));
+ if (string.IsNullOrEmpty(temp))
+ {
+ list.Add($"{ip} {domain}");
+ }
+ File.WriteAllLines(path, list.ToArray());
+ }
+
+ public static void Remove_Hosts(string hosts_str)
+ {
+ string path = System.Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\drivers\\etc\\hosts";
+ string[] hosts = File.ReadAllLines(path);
+ List list = hosts.ToList();
+ //int index = list.FindIndex(x => x.Contains(hosts_str));
+ //list.RemoveAt(index);
+ list.RemoveAll(x => x.Contains(hosts_str));
+ //foreach (string item in list.ToArray())
+ //{
+ // if (item.Contains(hosts_str))
+ // {
+ // list.Remove(item);
+ // }
+ //}
+ File.WriteAllLines(path, list.ToArray());
+ }
+
}
internal class MouseHook
diff --git a/PCRobot/app.manifest b/PCRobot/app.manifest
new file mode 100644
index 0000000..60a45a2
--- /dev/null
+++ b/PCRobot/app.manifest
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+