在 system() 调用中隐藏控制台窗口
继续这个问题
对于每个系统调用,该函数都会构造一组参数并将它们发送到另一个基于控制台的程序。有没有办法让每次调用都不会弹出控制台窗口?
我已经进行了搜索,但那些不是链接器问题的搜索对我来说不起作用。例如,我尝试了 _execl
调用和 System::Diagnostics::Process^ myProcess = gcnew System::Diagnostics::Process;
但它们不起作用。
_execl
将打开一个控制台窗口,滚动一堆内容(我猜是来自我调用的程序),然后关闭我的应用程序,甚至不执行它应该执行的操作。 System::Diagnostics::Process^ myProcess = gcnew System::Diagnostics::Process;
似乎也没有执行我想要的操作,因为应该包含文件的输出文件夹不包含任何内容。
所以我愿意接受想法。
Continuing from this question
With each system call, the function constructs a set of parameters and sends them off to another program that is just console-based. Is there a way I can make it so that no console window pops up for each call?
I've done a search but the ones that aren't a linker issue just aren't working for me. For instance, I tried the _execl
call and System::Diagnostics::Process^ myProcess = gcnew System::Diagnostics::Process;
but they aren't working.
The _execl
will bring a console window up, scroll a bunch of stuff (from the program I called I guess), then close the my app and not even do what it was supposed to do.
The System::Diagnostics::Process^ myProcess = gcnew System::Diagnostics::Process;
doesn't seem to execute what I want either because the output folder that should contain files, contains nothing.
So I'm open for ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CreateProcess API 为您提供所需的控制。例如:
如果将 CreateProcess 标志设置为 0(如上所述),辅助应用程序不会打开自己的控制台窗口,而是将其输出写入父窗口。要完全静默辅助应用程序,请查看其他 CreateProcess 标志,例如 CREATE_NO_WINDOW。
The CreateProcess API gives you the control you need. For example:
With the CreateProcess flags set to 0 as above, the secondary app does not open its own console window, and writes its output to the parent's window. To silence the secondary app entirely, look at other CreateProcess flags, e.g. CREATE_NO_WINDOW.