开发者

How do I run a commandline program without popping up the cmd.exe window?

I mostly 开发者_开发知识库use bash and perl and use Linux as my primary OS but now I'm on windows and playing around with C++ for the first time. Like a lot of Linux apps out there, I decided to keep the cli and gui elements separately.

I now have my CLI program working and I need to get started with writing a simple frontend to it. All that the frontend does is launch the cli app with a set of options and it should display the output from the program in a textbox and keep appending to it as the program outputs more and more text. The cli program is completely automated and runs on its own and there is no user interaction required after the program starts.

Can someeone show some sample code of launching a cli application without popping up the cmd.exe window or link me to some simple opensoure program similar to this so I can see how they've done it? The CLI program is a long running process. What do I need to do make sure it doesn't freeze the gui?

I'm not sure if I should use CLR or Native Win32 for the frontend. I've seen programs written in .NET and the menus look ugly.


If you choose to use .NET libraries in your UI controller you can use System.Diagnostics.Process to create the process and you can set ProcessStartInfo options to redirect StdOut so that you can read from it. There is an example on MSDN.


You can use CHP for running your application (CLI or windowed) in invisible window. Its usage is trivial:

CHP yourprogram.exe

And you can investigate its source, if you would like to know how it's done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜