Skip to content

Commit

Permalink
URL地址更新
Browse files Browse the repository at this point in the history
  • Loading branch information
cnxy committed May 11, 2021
1 parent 4956032 commit 0331216
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 25 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ https://download.ni.com/support/softlib/visa/NI-VISA/18.5/Windows/NIVISA1850runt
为了最佳的开发效果,开发时请使用最新的完整版本(截止目前为止,版本为20.0),下载链接如下:
https://download.ni.com/support/nipkg/products/ni-v/ni-visa/20.0/offline/ni-visa_20.0.0_offline.iso

注意:安装完整版后开发软件时,可以从GAC中引用完整版对应的Ivi.Visa.dll\NationalInstruments.Common.dll\NationalInstruments.Visa.dll,代替本项目中Library下的库文件。

## RS232
支持常见的RS232串口编程,一般地址为“ASRL1::INSTR”

Expand Down
25 changes: 22 additions & 3 deletions VISAInstrument/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static class Program
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Expand All @@ -26,13 +26,18 @@ static void Main()
MessageBox.Show(Resources.Running);
return;
}

if (!IsVisaExisted(out string message, out string[] visaSharedComponent, out string[] niVisaRuntime))
{
if (MessageBox.Show($"{message}\r\n\r\n{Resources.NeedToDownLoad}", @"错误",
MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes) return;
try
{
Process.Start(Resources.VISA32URL);
string url = GetVisaUrl();
if (!string.IsNullOrEmpty(url))
{
Process.Start(url);
}
}
catch (Exception ex)
{
Expand All @@ -46,6 +51,15 @@ static void Main()
Application.Run(new FrmMain());
}

private static string GetVisaUrl()
{
Version version = Environment.OSVersion.Version;
if (version.Major == 5)
{
return Resources.VISA32URLXP;
}
return version.Major >= 6 ? Resources.VISA32URLWIN7 : string.Empty;
}

private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Expand All @@ -57,7 +71,12 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc

if (result == DialogResult.Yes)
{
Process.Start(Resources.VISA32URL);

string url = GetVisaUrl();
if (!string.IsNullOrEmpty(url))
{
Process.Start(url);
}
}
}
else
Expand Down
15 changes: 12 additions & 3 deletions VISAInstrument/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions VISAInstrument/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@
<data name="VISA32Error" xml:space="preserve">
<value>加载VISA32错误,请保证已经安装VISA32运行时!</value>
</data>
<data name="VISA32URL" xml:space="preserve">
<value>https://github.com/cnxy/VISAInstrument/releases/download/1.0.0.0/NIVISA1700runtime.zip</value>
<data name="VISA32URLWIN7" xml:space="preserve">
<value>https://download.ni.com/support/softlib/visa/NI-VISA/18.5/Windows/NIVISA1850runtime.zip</value>
</data>
<data name="VISA32URLXP" xml:space="preserve">
<value>https://download.ni.com/support/softlib/visa/NI-VISA/15.5/Windows/NIVISA1550runtime.zip</value>
</data>
<data name="VISADownLoad" xml:space="preserve">
<value>点击“是”从弹出的网址进行下载并安装。</value>
Expand Down
1 change: 0 additions & 1 deletion VISAInstrument/VISAInstrument.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="VISA下载地址.md" />
</ItemGroup>
<ItemGroup>
<None Include="FodyWeavers.xml" />
Expand Down
16 changes: 0 additions & 16 deletions VISAInstrument/VISA下载地址.md

This file was deleted.

0 comments on commit 0331216

Please sign in to comment.