如何运行命令行程序而不弹出cmd.exe窗口?

发布于 2024-10-05 15:39:38 字数 450 浏览 0 评论 0原文

我主要使用 bash 和 perl,并使用 Linux 作为我的主要操作系统,但现在我在 Windows 上第一次尝试使用 C++。像许多 Linux 应用程序一样,我决定单独保留 cli 和 gui 元素。

现在我的 CLI 程序可以运行了,我需要开始为其编写一个简单的前端。前端所做的就是启动带有一组选项的 cli 应用程序,它应该在文本框中显示程序的输出,并随着程序输出越来越多的文本而不断附加到它。 cli 程序完全自动化并自行运行,程序启动后无需用户交互。

有人可以展示一些启动 cli 应用程序而不弹出 cmd.exe 窗口的示例代码,或者将我链接到一些与此类似的简单 opensoure 程序,以便我可以看到他们是如何完成的吗? CLI 程序是一个长时间运行的进程。我需要做什么才能确保它不会冻结 gui?

我不确定前端是否应该使用 CLR 还是 Native Win32。我见过用 .NET 编写的程序,但菜单看起来很丑。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉生梦死 2024-10-12 15:39:38

如果您选择在 UI 控制器中使用 .NET 库,则可以使用 System.Diagnostics.Process 创建进程,并且可以设置 ProcessStartInfo 选项来重定向 StdOut,以便可以从中读取。 MSDN 上有一个示例。

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.

糖粟与秋泊 2024-10-12 15:39:38

您可以使用 CHP 在不可见窗口中运行应用程序(CLI 或窗口化)。它的用法很简单:

CHP yourprogram.exe

如果您想知道它是如何完成的,您可以调查它的来源。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文