createProcess 函数的 DETACH_PROCESS 和 CREATE_NO_WINDOW 进程创建标志有什么区别 [英] What is the difference between DETACH_PROCESS and CREATE_NO_WINDOW process creation flags for createProcess function

查看:20
本文介绍了createProcess 函数的 DETACH_PROCESS 和 CREATE_NO_WINDOW 进程创建标志有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图了解这两个进程创建标志之间的区别.msdn 文档不清楚区别.

I have been trying to understand the difference between these two process creation flags. The msdn documentation is not clear about the distinction.

  • CREATE_NO_WINDOW 是否会导致进程有一个控制台(标准输入/输出流已初始化)而不显示窗口,而 DETACH_PROCESS 根本没有控制台?
  • 对子进程有什么影响?
  • 描述每种组合发生的行为矩阵是什么(父级有控制台,父级没有控制台)X(子可执行文件需要控制台(主),子可执行文件不需要控制台(WinMain)).?

推荐答案

区别在于启动的进程能做什么.在这两种情况下,它都没有控制台.但是使用 CREATE_NO_WINDOW 选项,它可以调用 AttachConsole(ATTACH_PARENT_PROCESS) 并访问父控制台窗口(如果可用).当您指定 DETACH_PROCESS 时,这将不起作用.唯一的选择是让启动的进程使用 AllocConsole() 创建自己的控制台.

The difference is in what the started process can do. In both cases it won't have a console. But with the CREATE_NO_WINDOW option it can call AttachConsole(ATTACH_PARENT_PROCESS) and get access to the parent's console window (if available). That explicitly will not work when you specify DETACH_PROCESS. The only option then is for the started process to use AllocConsole() to create its own console.

或者换句话说,您可以确定启动的进程将永远无法通过使用 DETACH_PROCESS 进入您自己的控制台.

Or in other words, you can be sure that the started process will never be able to chatter into your own console by using DETACH_PROCESS.

这篇关于createProcess 函数的 DETACH_PROCESS 和 CREATE_NO_WINDOW 进程创建标志有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆