mirror of https://github.com/2dust/v2rayN
parent
a7e215dd5b
commit
9f3b128044
|
@ -41,7 +41,7 @@
|
||||||
this.btnClose.Location = new System.Drawing.Point(367, 118);
|
this.btnClose.Location = new System.Drawing.Point(367, 118);
|
||||||
this.btnClose.Name = "btnClose";
|
this.btnClose.Name = "btnClose";
|
||||||
this.btnClose.Size = new System.Drawing.Size(184, 89);
|
this.btnClose.Size = new System.Drawing.Size(184, 89);
|
||||||
this.btnClose.TabIndex = 6;
|
this.btnClose.TabIndex = 1;
|
||||||
this.btnClose.Text = "&Exit(退出)";
|
this.btnClose.Text = "&Exit(退出)";
|
||||||
this.btnClose.UseVisualStyleBackColor = true;
|
this.btnClose.UseVisualStyleBackColor = true;
|
||||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
this.btnOK.Location = new System.Drawing.Point(81, 118);
|
this.btnOK.Location = new System.Drawing.Point(81, 118);
|
||||||
this.btnOK.Name = "btnOK";
|
this.btnOK.Name = "btnOK";
|
||||||
this.btnOK.Size = new System.Drawing.Size(184, 89);
|
this.btnOK.Size = new System.Drawing.Size(184, 89);
|
||||||
this.btnOK.TabIndex = 7;
|
this.btnOK.TabIndex = 0;
|
||||||
this.btnOK.Text = "&Upgrade(升级)";
|
this.btnOK.Text = "&Upgrade(升级)";
|
||||||
this.btnOK.UseVisualStyleBackColor = true;
|
this.btnOK.UseVisualStyleBackColor = true;
|
||||||
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
||||||
|
@ -89,7 +89,6 @@
|
||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "v2rayUpgrade";
|
this.Text = "v2rayUpgrade";
|
||||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
|
|
@ -8,28 +8,24 @@ namespace v2rayUpgrade
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
private string[] _args;
|
private readonly string defaultFilename = "v2ray-windows.zip";
|
||||||
private string _tempFileName = "v2rayUpgradeTemp.zip";
|
private string fileName;
|
||||||
|
|
||||||
|
|
||||||
public MainForm(string[] args)
|
public MainForm(string[] args)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_args = args;
|
if (args.Length > 0)
|
||||||
}
|
|
||||||
|
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
|
fileName = args[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void showWarn(string message)
|
||||||
|
{
|
||||||
|
MessageBox.Show(message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOK_Click(object sender, EventArgs e)
|
private void btnOK_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_args.Length <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process[] existing = Process.GetProcessesByName("v2rayN");
|
Process[] existing = Process.GetProcessesByName("v2rayN");
|
||||||
|
@ -45,20 +41,25 @@ namespace v2rayUpgrade
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Failed to close v2rayN(关闭v2rayN失败)." + ex.StackTrace);
|
showWarn("Failed to close v2rayN(关闭v2rayN失败)." + ex.StackTrace);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fileName = GetPath(_tempFileName);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.Delete(fileName);
|
|
||||||
File.Copy(_args[0], fileName);
|
|
||||||
if (!File.Exists(fileName))
|
if (!File.Exists(fileName))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Upgrade Failed, File Not Exist(升级失败,文件不存在).");
|
if (File.Exists(defaultFilename))
|
||||||
|
{
|
||||||
|
fileName = defaultFilename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showWarn("Upgrade Failed, File Not Exist(升级失败,文件不存在).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string startKey = "v2rayN/";
|
string startKey = "v2rayN/";
|
||||||
|
|
||||||
|
@ -86,23 +87,13 @@ namespace v2rayUpgrade
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Upgrade Failed(升级失败)." + ex.StackTrace);
|
showWarn("Upgrade Failed(升级失败)." + ex.StackTrace);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally
|
|
||||||
{
|
|
||||||
File.Delete(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageBox.Show("Upgrade successed(升级成功)");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Process.Start("v2rayN.exe");
|
Process.Start("v2rayN.exe");
|
||||||
}
|
MessageBox.Show("Upgrade successed(升级成功)", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,17 +108,9 @@ namespace v2rayUpgrade
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string StartupPath()
|
public static string StartupPath()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string exePath = GetExePath();
|
|
||||||
return exePath.Substring(0, exePath.LastIndexOf("\\", StringComparison.Ordinal));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
{
|
||||||
return Application.StartupPath;
|
return Application.StartupPath;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public static string GetPath(string fileName)
|
public static string GetPath(string fileName)
|
||||||
{
|
{
|
||||||
string startupPath = StartupPath();
|
string startupPath = StartupPath();
|
||||||
|
|
|
@ -11,12 +11,6 @@ namespace v2rayUpgrade
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length <= 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Please use v2rayN to upgrade(请用v2rayN升级)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new MainForm(args));
|
Application.Run(new MainForm(args));
|
||||||
|
|
|
@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("v2rayUpgrade")]
|
[assembly: AssemblyProduct("v2rayUpgrade")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2019")]
|
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||||
// 方法是按如下所示使用“*”: :
|
// 方法是按如下所示使用“*”: :
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("1.1.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||||
|
|
Loading…
Reference in New Issue