diff --git a/RevokeMsgPatcher.MultiInstance/FormMultiInstance.Designer.cs b/RevokeMsgPatcher.MultiInstance/FormMultiInstance.Designer.cs
index 1ab1687..11b3e4a 100644
--- a/RevokeMsgPatcher.MultiInstance/FormMultiInstance.Designer.cs
+++ b/RevokeMsgPatcher.MultiInstance/FormMultiInstance.Designer.cs
@@ -33,14 +33,17 @@
this.btnChoosePath = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.button1 = new System.Windows.Forms.Button();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
+ this.startNum = new System.Windows.Forms.NumericUpDown();
+ this.btnStart = new System.Windows.Forms.Button();
+ this.linkLabel1 = new System.Windows.Forms.LinkLabel();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.startNum)).BeginInit();
this.SuspendLayout();
//
// txtPath
//
- this.txtPath.Location = new System.Drawing.Point(92, 48);
+ this.txtPath.Location = new System.Drawing.Point(86, 60);
this.txtPath.Name = "txtPath";
this.txtPath.Size = new System.Drawing.Size(332, 21);
this.txtPath.TabIndex = 7;
@@ -48,7 +51,7 @@
// lblPathTag
//
this.lblPathTag.AutoSize = true;
- this.lblPathTag.Location = new System.Drawing.Point(21, 51);
+ this.lblPathTag.Location = new System.Drawing.Point(15, 63);
this.lblPathTag.Name = "lblPathTag";
this.lblPathTag.Size = new System.Drawing.Size(65, 12);
this.lblPathTag.TabIndex = 6;
@@ -56,17 +59,18 @@
//
// btnChoosePath
//
- this.btnChoosePath.Location = new System.Drawing.Point(430, 47);
+ this.btnChoosePath.Location = new System.Drawing.Point(424, 59);
this.btnChoosePath.Name = "btnChoosePath";
- this.btnChoosePath.Size = new System.Drawing.Size(50, 23);
+ this.btnChoosePath.Size = new System.Drawing.Size(36, 23);
this.btnChoosePath.TabIndex = 8;
this.btnChoosePath.Text = "...";
this.btnChoosePath.UseVisualStyleBackColor = true;
+ this.btnChoosePath.Click += new System.EventHandler(this.btnChoosePath_Click);
//
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(106, 9);
+ this.label1.Location = new System.Drawing.Point(84, 151);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(293, 24);
this.label1.TabIndex = 9;
@@ -75,45 +79,83 @@
// label2
//
this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(21, 77);
+ this.label2.Location = new System.Drawing.Point(15, 95);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(65, 12);
this.label2.TabIndex = 11;
this.label2.Text = "多开个数:";
//
- // numericUpDown1
+ // startNum
//
- this.numericUpDown1.Location = new System.Drawing.Point(92, 75);
- this.numericUpDown1.Maximum = new decimal(new int[] {
+ this.startNum.Location = new System.Drawing.Point(86, 91);
+ this.startNum.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(55, 21);
- this.numericUpDown1.TabIndex = 12;
- this.numericUpDown1.Value = new decimal(new int[] {
+ this.startNum.Minimum = new decimal(new int[] {
+ 2,
+ 0,
+ 0,
+ 0});
+ this.startNum.Name = "startNum";
+ this.startNum.Size = new System.Drawing.Size(55, 21);
+ this.startNum.TabIndex = 12;
+ this.startNum.Value = new decimal(new int[] {
2,
0,
0,
0});
//
- // button1
+ // btnStart
//
- this.button1.Location = new System.Drawing.Point(211, 95);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(108, 32);
- this.button1.TabIndex = 13;
- this.button1.Text = "点击启动!";
- this.button1.UseVisualStyleBackColor = true;
+ this.btnStart.Location = new System.Drawing.Point(369, 91);
+ this.btnStart.Name = "btnStart";
+ this.btnStart.Size = new System.Drawing.Size(91, 23);
+ this.btnStart.TabIndex = 13;
+ this.btnStart.Text = "点击启动!";
+ this.btnStart.UseVisualStyleBackColor = true;
+ this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
+ //
+ // linkLabel1
+ //
+ this.linkLabel1.AutoSize = true;
+ this.linkLabel1.Location = new System.Drawing.Point(284, 95);
+ this.linkLabel1.Name = "linkLabel1";
+ this.linkLabel1.Size = new System.Drawing.Size(41, 12);
+ this.linkLabel1.TabIndex = 15;
+ this.linkLabel1.TabStop = true;
+ this.linkLabel1.Text = "GitHub";
+ this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(177, 95);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(101, 12);
+ this.label3.TabIndex = 14;
+ this.label3.Text = "软件主页(开源):";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(12, 9);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(323, 36);
+ this.label4.TabIndex = 16;
+ this.label4.Text = "注意:\r\n1. 使用本程序多开前不能存在正在运行的微信进程。\r\n2. 多开的成功率取决于你的机器性能,不保证每次都能成功";
//
// FormMultiInstance
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(513, 139);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.numericUpDown1);
+ this.ClientSize = new System.Drawing.Size(472, 133);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.linkLabel1);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.btnStart);
+ this.Controls.Add(this.startNum);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtPath);
@@ -121,7 +163,7 @@
this.Controls.Add(this.btnChoosePath);
this.Name = "FormMultiInstance";
this.Text = "微信多开小工具";
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.startNum)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -134,8 +176,11 @@
private System.Windows.Forms.Button btnChoosePath;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
- private System.Windows.Forms.NumericUpDown numericUpDown1;
- private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.NumericUpDown startNum;
+ private System.Windows.Forms.Button btnStart;
+ private System.Windows.Forms.LinkLabel linkLabel1;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
}
}
diff --git a/RevokeMsgPatcher.MultiInstance/FormMultiInstance.cs b/RevokeMsgPatcher.MultiInstance/FormMultiInstance.cs
index 5080549..1f566ef 100644
--- a/RevokeMsgPatcher.MultiInstance/FormMultiInstance.cs
+++ b/RevokeMsgPatcher.MultiInstance/FormMultiInstance.cs
@@ -1,8 +1,11 @@
-using System;
+using Microsoft.Win32;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
+using System.Diagnostics;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -15,6 +18,94 @@ namespace RevokeMsgPatcher.MultiInstance
public FormMultiInstance()
{
InitializeComponent();
+ string installFolder = FindInstallPathFromRegistry("Wechat");
+ if (!string.IsNullOrEmpty(installFolder))
+ {
+ string wechatPath = Path.Combine(installFolder, "WeChat.exe");
+ if (File.Exists(wechatPath))
+ {
+ txtPath.Text = wechatPath;
+ }
+ }
+ }
+
+ private void btnChoosePath_Click(object sender, EventArgs e)
+ {
+ OpenFileDialog dialog = new OpenFileDialog
+ {
+ Multiselect = false,
+ Title = "请选择微信启动主程序",
+ Filter = "微信主程序|WeChat.exe"
+ };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ txtPath.Text = dialog.FileName;
+ }
+ }
+
+ private void btnStart_Click(object sender, EventArgs e)
+ {
+ if (File.Exists(txtPath.Text))
+ {
+ // 检测微信进程是否存在
+ Process[] ps = Process.GetProcessesByName("WeChat");
+ if (ps.Length > 0)
+ {
+ DialogResult result = MessageBox.Show("当前存在运行中的微信进程,请先关闭当前微信才能使用该功能。点击【确定】强制关闭当前所有微信进程并进行多开,点击【取消】不做任何处理。", "当前存在运行中的微信进程", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
+ if (result == DialogResult.OK)
+ {
+ foreach (Process p in ps)
+ p.Kill();
+ }
+ else
+ {
+ return;
+ }
+ }
+ // 启动多个实例
+ for (int i = 0; i < startNum.Value; i++)
+ {
+ Process.Start(txtPath.Text);
+ }
+ }
+ }
+
+ private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ {
+ Process.Start("https://github.com/huiyadanli/RevokeMsgPatcher");
+ }
+
+ ///
+ /// 从注册表中寻找安装路径
+ ///
+ ///
+ /// 安装信息的注册表键名
+ /// 微信:WeChat
+ /// QQ:{052CFB79-9D62-42E3-8A15-DE66C2C97C3E}
+ /// TIM:TIM
+ ///
+ /// 安装路径
+ public static string FindInstallPathFromRegistry(string uninstallKeyName)
+ {
+ try
+ {
+ RegistryKey key = Registry.LocalMachine.OpenSubKey($@"Software\Microsoft\Windows\CurrentVersion\Uninstall\{uninstallKeyName}");
+ if (key == null)
+ {
+ return null;
+ }
+ object installLocation = key.GetValue("InstallLocation");
+ key.Close();
+ if (installLocation != null && !string.IsNullOrEmpty(installLocation.ToString()))
+ {
+ return installLocation.ToString();
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ }
+ return null;
}
}
}