locked
Passing parameters from console applications and Windows Forms RRS feed

  • Question

  • Hi to all, i'm new to this forum and to the world of .NET in general.

    I need some suggestions about this...

    I have an application written in ANSI C++ and i want to pass parameters from this executable to a Windows Form and use these like a simple front-and that can help me to drive the console application.

    Suggest me some technologies ...

    Tanks to all.
    Saturday, November 17, 2007 7:45 PM

Answers

  • In your console application you can change the Main() method from:

    static void Main()

    to

    static void Main(string[] argv), then when you instantiate an instance of your form you can send the arguments to your form via the constructor like below.

    MyForm form = new MyForm(argv);

    Now change your forms constructor from

    MyForm()

    to

    MyForm(string[] argv), then you can implement a private member and a public property to store the arguments, or simply handle the arugments in your constructor.
    Tuesday, November 20, 2007 7:15 AM

All replies

  • You can add a string array as an argument to your forms constructor and have a private member that holds the data.

    private string[] argv;

    MyForm(string[] argv)
    {
    this.argv = argv;
    }

    You can pass your arguments when you instantiate an instance of your form.
    Saturday, November 17, 2007 8:01 PM
  • Following this approach, i must design the console application to give it the possibility to send a string to the form !

    After, in the Windows Form application, i can code a handler for these strings !

    This is what you suggest me ?
    Sunday, November 18, 2007 3:23 PM
  • In your console application you can change the Main() method from:

    static void Main()

    to

    static void Main(string[] argv), then when you instantiate an instance of your form you can send the arguments to your form via the constructor like below.

    MyForm form = new MyForm(argv);

    Now change your forms constructor from

    MyForm()

    to

    MyForm(string[] argv), then you can implement a private member and a public property to store the arguments, or simply handle the arugments in your constructor.
    Tuesday, November 20, 2007 7:15 AM
  • I think that is possible to implement a module based on "IpcChannel Class", that Provide a channel implementation that uses the IPC protocol to transmit messages.

    Yes or not ?
    Friday, November 23, 2007 5:03 PM