可以编译和运行C程序的VB.NET应用程序
这些天我正在开发一个 VB.NET 应用程序,它可以用来编辑、编译和运行 C 程序。有人可以告诉我如何从 VB 程序中调用 cl.exe 进程,以及如何在控制台窗口本身中运行该程序。
目前我只准备好了编辑器。这样,我们就可以输入一个程序并以“.c”扩展名保存它。现在我的表单上有 2 个按钮 - “编译”和“运行”。当用户单击“编译”按钮时,程序应传递给 cl.exe 进程,并且错误应显示在另一个文本框或 DOS 中(本身黑屏)。当用户单击“运行”按钮时,刚刚创建的“.exe”文件应该被执行。
有没有办法将一些文件与我的程序一起附加,以便计算机中没有安装“C”的人也可以使用我的应用程序编辑、编译和运行 C 程序?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要捕获编译器或编译和链接程序的输出,请使用 System.Diagnostics.Process.StandardOutput 属性来检索 System.IO.StreamReader 实例。
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.
您可以使用 System.Diagnostics.Process 类来做到这一点。
您可以使用 Start 方法启动任何可执行文件。您可以传递参数等,就像从命令行一样。
添加
您可以使用Process.StartInfo.RedirectStandardOutput 属性。
重定向错误、输入等也有类似的方法。
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.