K
K
Konstantin Malyarov2017-03-26 16:58:35
C++ / C#
Konstantin Malyarov, 2017-03-26 16:58:35

How to pass external parameter to Windows Form Application?

How to run a program and pass an external parameter there?
"C:\formApplication.exe -p param"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
leremin, 2017-03-26
@leremin

Look towards Environment.GetCommandLineArgs(). But if you need the Unix form "-p, --property", then google "C# getopt" - there are many implementations.

U
unsafePtr, 2017-03-26
@unsafePtr

Declare a form constructor with a parameter and call it in Main

public MainForm(string parameter) : this()
{
   this.Parameter = parameter ?? String.Empty;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question