Eran Buddhika
Eran Buddhika

Reputation: 15

Send values from one application form to another application form in c#

I have a c# 2 application. I want to send user name HQAdmin.exe

I use this code.

 Process.Start(Application.StartupPath + @"\HQAdmin.exe", "" + strUserGroupID + " " + strUserID + " " + strUserName + " " + strPDateDMY + " " + strPDateMDY + "");

How can get that values with in HQAdmin application?

I have setting variable, string username I use is code get user name

Properties.Settings.Default.username ;

that code doesn't work, how can do that?

Upvotes: 0

Views: 1107

Answers (2)

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137438

What you're showing in that example, is passing command-line arguments to the process when it is started. How you handle those arguments in the child process depends on what language it's written in. In most languages, the command-line arguments are passed as arguments to the main function.

C#

static void Main(string[] args) {
    string username = "default";

    if (args.Length >= 1) {
        username = args[0];
}

See also: Main() and Command-Line Arguments (C# Programming Guide)

I'm not a VB.net programmer, but it appears you can use My.Application.CommandLineArgs there.

Upvotes: 2

Rob
Rob

Reputation: 11788

Try to read the arguments like this:

string[] args = Environment.GetCommandLineArgs();

foreach(string arg in args){
     //do something
}

Edit: Sorry, this is for C#, but I think you get the idea.

Upvotes: 1

Related Questions