Skip to content

Commit 1fddbed

Browse files
author
Tomozaki
committed
增加版本判断功能
1 parent 8ccf67d commit 1fddbed

3 files changed

Lines changed: 54 additions & 13 deletions

File tree

SerialPortHelperLib/Properties/AssemblyInfo.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
// 控制。更改这些特性值可修改
77
// 与程序集关联的信息。
88
[assembly: AssemblyTitle("SerialPortHelperLib")]
9-
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyDescription("串口助手类库")]
1010
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("Microsoft")]
11+
[assembly: AssemblyCompany("Chishin")]
1212
[assembly: AssemblyProduct("SerialPortHelperLib")]
13-
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
14-
[assembly: AssemblyTrademark("")]
13+
[assembly: AssemblyCopyright("Copyright © Chishin 2018")]
14+
[assembly: AssemblyTrademark("SerialPortHelperLib for Chishin")]
1515
[assembly: AssemblyCulture("")]
1616

1717
// 将 ComVisible 设置为 false 会使此程序集中的类型
@@ -32,5 +32,5 @@
3232
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
3333
//通过使用 "*",如下所示:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("18.6.8.0")]
36+
[assembly: AssemblyFileVersion("18.6.8.0")]

SerialPortHelperTest/Program.cs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
35
using System.Linq;
46
using System.Windows.Forms;
57

@@ -13,9 +15,48 @@ static class Program
1315
[STAThread]
1416
static void Main()
1517
{
16-
Application.EnableVisualStyles();
17-
Application.SetCompatibleTextRenderingDefault(false);
18-
Application.Run(new frmMain());
18+
string strError;
19+
if (CheckInit(out strError))
20+
{
21+
Application.EnableVisualStyles();
22+
Application.SetCompatibleTextRenderingDefault(false);
23+
Application.Run(new frmMain());
24+
}
25+
else
26+
{
27+
if (MessageBox.Show(strError, "无法启动程序", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK)
28+
{
29+
System.Diagnostics.Process.Start("https://github.com/xiaoxinpro/SerialPortHelper/releases");
30+
}
31+
Application.Exit();
32+
}
33+
34+
}
35+
36+
static bool CheckInit(out string message)
37+
{
38+
message = "";
39+
40+
//获取运行目录
41+
string strPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
42+
43+
//判断SerialPortHelperLib.dll是否有效
44+
string strPathSerialPortHelperLib = strPath + @"SerialPortHelperLib.dll";
45+
if (!File.Exists(strPathSerialPortHelperLib))
46+
{
47+
message = "缺少SerialPortHelperLib.dll文件,请安装最新版本。";
48+
return false;
49+
}
50+
51+
//判断SerialPortHelperLib.dll版本号
52+
Version verSerialPortHelperLib = new Version(FileVersionInfo.GetVersionInfo(strPathSerialPortHelperLib).FileVersion);
53+
if (verSerialPortHelperLib < new Version("18.6.8.0"))
54+
{
55+
message = "类库文件SerialPortHelperLib.dll版本过低,请安装最新版本。";
56+
return false;
57+
}
58+
59+
return true;
1960
}
2061
}
2162
}

SerialPortHelperTest/Properties/AssemblyInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
// 控制。更改这些特性值可修改
77
// 与程序集关联的信息。
88
[assembly: AssemblyTitle("SerialPortHelperTest")]
9-
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyDescription("串口助手测试")]
1010
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("Microsoft")]
11+
[assembly: AssemblyCompany("Chishin")]
1212
[assembly: AssemblyProduct("SerialPortHelperTest")]
13-
[assembly: AssemblyCopyright("Copyright © Microsoft 2018")]
14-
[assembly: AssemblyTrademark("")]
13+
[assembly: AssemblyCopyright("Copyright © Chishin 2018")]
14+
[assembly: AssemblyTrademark("SerialPortHelperTest for Chishin")]
1515
[assembly: AssemblyCulture("")]
1616

1717
// 将 ComVisible 设置为 false 会使此程序集中的类型

0 commit comments

Comments
 (0)