Skip to content

QUESTION: HOW TO PASS PARAMETERS BETWEEN TWO PROGRAMS??

franky

Asked Sep 11, 2005, 10:22 AM EDT5 answers
Share
LinkedInX
Hello!

I'm new in c# programming and I need you to help me with this problem:

I've created two programs in C#. The first one called "FM" and is only a program with a lot of functions. The second one called "MCDU" and is the main program.
The problem is that I need to pass some parameters of "MCDU" to "FM" in order that the second program executes with this parameters one of the functions that has in its code. So, how I pass from "MCDU" the parameters to "FM" and also how I return new parameters from "FM" to MCDU?

Thanks in advance and if you need a better explanation please ask for it!

Franky

5 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    hi 

    i am a beginner too but 

    i think that if the 2 programs run in separation (independent no form call the other form ),u 

    need to use remoting or network programming or com+

    remoting enables u for example to create an object in a program and to use it in another program 

    remoting in fact is based on network programming but with specific message formatting between 

    the 2 programms,and wish support of classes to help in the process of transfering objects
    ,if u use network programming u will define of course the message format u need

    i suggest that u read about remoting.

    best wishes 
    0
  • 0
    Thanks for your answer, I've have found that it can be made throghout processes.
    0
  • 0
    hi 

    can u give an example of how to use processes to do that ,as it may be an easier solution if u 
    are right 

    do u mean that one form is calling the other (run it) using something like Process.Start()
    and pass some arguments to the other program ?

    thanks
    0
  • 0

    This is an example caught from csharpfriends.
    In this example the App2 should know if from App1 a checkbox has been checked or not.
    Here you have the code, I hope it helps you as well as it helped me.

    Call the App2 form App1 with

    System.Diagnostics.Process.Start("App2.exe","0");

    if the checkbox is not checked and

    System.Diagnostics.Process.Start("App2.exe","1");

    if the checkbox is checked.

    From the App2 you can get the argument (0,1) from

    using System.Text;
    using System.Text.RegularExpressions;

    Regex Splits=new Regex(@" ");
    string param=Splits.Split(Environment.CommandLine);

    if(param.Length>1)
    {
    param[1]; // is 0 or 1
    }

    0
  • 0
    hi

    then in this case u are running a program from the other and pass parameters for it 

    but in case that the 2 programms run independently so u cannot pass parameters this way

    and thanks too much for the example
    0