从网上自动获取最新的补丁信息用于修改

This commit is contained in:
huiyadanli 2019-08-03 19:38:02 +08:00
parent 43ce6ecb96
commit 55e98b5d49
4 changed files with 58 additions and 5 deletions

View File

@ -36,6 +36,7 @@
this.label1 = new System.Windows.Forms.Label();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.btnRestore = new System.Windows.Forms.Button();
this.lblUpdatePachJson = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label2
@ -109,11 +110,23 @@
this.btnRestore.UseVisualStyleBackColor = true;
this.btnRestore.Click += new System.EventHandler(this.btnRestore_Click);
//
// lblUpdatePachJson
//
this.lblUpdatePachJson.AutoSize = true;
this.lblUpdatePachJson.Cursor = System.Windows.Forms.Cursors.Hand;
this.lblUpdatePachJson.Location = new System.Drawing.Point(198, 44);
this.lblUpdatePachJson.Name = "lblUpdatePachJson";
this.lblUpdatePachJson.Size = new System.Drawing.Size(131, 12);
this.lblUpdatePachJson.TabIndex = 9;
this.lblUpdatePachJson.Text = "获取最新补丁信息中...";
this.lblUpdatePachJson.Click += new System.EventHandler(this.lblUpdatePachJson_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(523, 69);
this.Controls.Add(this.lblUpdatePachJson);
this.Controls.Add(this.btnRestore);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.label1);
@ -125,6 +138,7 @@
this.Name = "FormMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "微信防撤回补丁";
this.Load += new System.EventHandler(this.FormMain_Load);
this.ResumeLayout(false);
this.PerformLayout();
@ -138,6 +152,7 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.Button btnRestore;
private System.Windows.Forms.Label lblUpdatePachJson;
}
}

View File

@ -1,5 +1,7 @@
using System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RevokeMsgPatcher
@ -125,5 +127,36 @@ namespace RevokeMsgPatcher
{
System.Diagnostics.Process.Start("https://github.com/huiyadanli/RevokeMsgPatcher");
}
private async void FormMain_Load(object sender, EventArgs e)
{
// 异步获取最新的补丁信息
Task<string> t = new Task<string>(() =>
{
return new WebClient().DownloadString("https://huiyadanli.coding.me/i/patch.json");
});
t.Start();
string json = await t;
if(string.IsNullOrEmpty(json))
{
lblUpdatePachJson.Text = "获取失败";
} else
{
patcher.SetNewPatchJson(json);
lblUpdatePachJson.Text = "获取成功";
}
}
private void lblUpdatePachJson_Click(object sender, EventArgs e)
{
string versions = "";
patcher.TargetFiles.ForEach(t =>
{
versions += t.Version + Environment.NewLine;
});
MessageBox.Show("当前所支持的微信版本:" + Environment.NewLine + versions);
}
}
}

View File

@ -1,5 +1,4 @@
using RevokeMsgPatcher.Model;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -9,7 +8,6 @@ namespace RevokeMsgPatcher
{
public class Patcher
{
private string intallPath;
public string IntallPath
{
@ -40,12 +38,20 @@ namespace RevokeMsgPatcher
private List<TargetFile> targetFiles;
private TargetFile currentFile;
public List<TargetFile> TargetFiles { get => targetFiles; }
public Patcher()
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
targetFiles = serializer.Deserialize<List<TargetFile>>(Properties.Resources.PatchJson);
}
public void SetNewPatchJson(string json)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
targetFiles = serializer.Deserialize<List<TargetFile>>(json);
}
public string JudgeVersion()
{
string sha1 = Util.ComputeFileSHA1(dllPath);
@ -63,7 +69,6 @@ namespace RevokeMsgPatcher
return t.Version;
}
}
return null;
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
//[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3")]
[assembly: AssemblyFileVersion("0.3")]
[assembly: AssemblyVersion("0.4")]
[assembly: AssemblyFileVersion("0.4")]