createProcess函数的DETACH_PROCESS和CREATE_NO_WINDOW进程创建标志之间有什么区别 [英] What is the difference between DETACH_PROCESS and CREATE_NO_WINDOW process creation flags for createProcess function
问题描述
我一直试图了解这两个进程创建标志之间的区别. msdn文档尚不清楚区别.
I have been trying to understand the difference between these two process creation flags. The msdn documentation is not clear about the distinction.
- 当DETACH_PROCESS根本没有控制台时,CREATE_NO_WINDOW是否使进程具有控制台(初始化标准输入/输出流)而没有显示窗口?
- 对一个孩子一个孩子的过程有什么影响?
- 将描述在(父级具有控制台,父级没有控制台)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屋!