Executing a program in a new process from a Visual COBOL managed .NET application

0 Likes
over 8 years ago

Problem:

Customer is developing a Windows Forms application in Visual COBOL for Visual Studio and they are looking for a way to start a non-COBOL executable like a text editor directly from within their application.

How can this be done?

Resolution

You can use the .NET framework Process class to execute all types of programs including .EXEs or to launch an application such as an editor by specifying just a filename to associate with it.

Look at the following link which provides some good examples:

http://www.dotnetperls.com/process-start

The following example will execute the text editor such as notepad that is associated with the .txt extension on your system and open up the file example.txt.

     $set ilusing"System.Diagnostics"
       class-id execprogram.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       working-storage section.
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
           invoke type Process::Start("example.txt")
           goback.
       end method.

Comment List
Anonymous
Related Discussions
Recommended