向 VB.Net 应用程序添加命令行参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7218217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 15:51:35  来源:igfitidea点击:

Adding command line arguments to VB.Net application

.netvisual-studio-2010command-linecommand-line-interfacecommand-line-arguments

提问by Myles Gray

I have a windows forms based application made by another programmer and I need to add a few command line switches to it's primary output exeso that I can pass arguments like:

我有一个由另一个程序员制作的基于 Windows 窗体的应用程序,我需要向它添加一些命令行开关,primary output exe以便我可以传递如下参数:

program.exe -reinitialiseor program.exe -sync

program.exe -reinitialise或者 program.exe -sync

I have found some docs online but all seem to be in C# and are for command line only programs.

我在网上找到了一些文档,但似乎都在 C# 中,并且仅适用于命令行程序。

This program installs via an .msi and the .exe is only constructed at the end.

该程序通过 .msi 安装,而 .exe 仅在最后构建。

So my questions are:

所以我的问题是:

  1. How do I add command line switches to a VB.Net application?

  2. Where/What form do I add the parser to so that the primary output .exe accepts the args?

  1. 如何向 VB.Net 应用程序添加命令行开关?

  2. 我在哪里/什么形式添加解析器,以便主输出 .exe 接受 args?

回答by Brandon Langley

Similar to C/C#, you get them as an array. Different from C/C#, you obtain them as a read-only property from the application itself (My.Application.CommandlineArgs)

与 C/C# 类似,您可以将它们作为数组获取。与 C/C# 不同,您可以从应用程序本身 (My.Application.CommandlineArgs) 获取它们作为只读属性

http://msdn.microsoft.com/en-us/library/z2d603cy(v=vs.80).aspx#Y550

http://msdn.microsoft.com/en-us/library/z2d603cy(v=vs.80).aspx#Y550

Code sample on that page (for VB) should show you what you need i think...

该页面上的代码示例(用于 VB)应该向您展示我认为您需要什么......