0

These days I'm working on a VB.NET application which can be used to edit, compile and run C programs. Can someone tell me how I can call a cl.exe process from within my VB program and also that how do I run the program in the console widow itself.

Presently I have only the editor ready. With that one can type in a program and save it with a ".c" extension. Now there are 2 buttons on my form - "Compile" and "Run". When the user clicks on the "Compile" button, the program should be passed to the cl.exe process and the errors should be displayed in another textbox or the DOS(black screen itself). And when the user clicks on the "Run" button, the ".exe" file which just got created should get executed.

Is there any way to attach some files along with my program so that the people who do not have "C" installed in their computers can also edit, compile and run C programs using my application?

1
  • Why not use one of the excellent free products like Eclipse or Visual C++ Express? Commented Apr 9, 2010 at 8:00

2 Answers 2

2

You can use the System.Diagnostics.Process class to do this.

You can launch any executable using the Start method. You an pass arguments, etc, just like you would from the command line.

Added

You can redirect the output of the program using the Process.StartInfo.RedirectStandardOutput property.

There are similar methods for redirecting errors, input, etc.

Sign up to request clarification or add additional context in comments.

2 Comments

@David - How do I redirect the errors, input and output to/from a textbox from the compiler results?
Using the Process.StartInfo.RedirectStandardOutput, RedirectStandardError, ec. See here: msdn.microsoft.com/en-us/library/…
1

To capture the output of the compiler or the compiled and linked program, use the System.Diagnostics.Process.StandardOutput property to retrieve a System.IO.StreamReader instance.

1 Comment

@Judge Maygarden - I'll check out the property from the MSDN Library installed in ma system. Thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.