CreateProcess 函数出现问题!
我有我的主应用程序,从我的主应用程序我将调用另一个 模块(第三方)在我的主应用程序中执行一个小操作,当我调用该模块时..它会处理特定时间(例如5秒)。在处理时,它会在命令窗口中显示进程以及一些信息..现在我的主应用程序等待被调用的模块完成其进程。现在我的问题是..如何隐藏此命令窗口而不干扰其进程..我尝试使用 createprocess 但它似乎不起作用...
例如:我的主应用程序是父进程,被调用的应用程序是子进程。父进程应该独立于子进程。
int main()
{
execl("c:\\users\\rakesh\\Desktop\\calledapplication.exe","c:\\users\\rakesh\\Desktop \\calledapplication.exe",0);
}
code in calledapplication
int main
{
printf("Rakesh");
}
如果您运行第一个程序,请检查下面的示例,考虑上述内容...输出将出现在相同的位置 命令窗口(不应该是这样)...我希望主应用程序创建进程,但它不应该受到子进程的影响。
I have my main application ,from my main application I will be calling another
module(third party) to perform a small operation in my main application,when I call that module..it processes for a particular time say 5 sec.while its proccessing it shows the process in the commmand window with some information..now my main application waits until the called module finishes its process.Now my Question is..how to do I hide this command window without disturbing its process..I tried to use the createprocess but it seems to not work...
for example: my main application is the Parent process and the called application is child process..Parent process should be independent of the child process..check my example below
int main()
{
execl("c:\\users\\rakesh\\Desktop\\calledapplication.exe","c:\\users\\rakesh\\Desktop \\calledapplication.exe",0);
}
code in calledapplication
int main
{
printf("Rakesh");
}
now considering the above if you run the first program...output would appear in the same
command window(It shouldnt be like that)...I want the main application to create the process but it should not be affected by child process.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在
CreateProcess
的dwCreationFlags
参数中传递CREATE_NO_WINDOW
。Pass
CREATE_NO_WINDOW
in thedwCreationFlags
parameter ofCreateProcess
.您谈到了“命令窗口”,所以我认为子级是控制台应用程序。
在这种情况下,您可以在单独的控制台中创建进程,并可选择强制新控制台图标化或隐藏。
以下代码启动一个解释批处理文件 (mytest.bat) 的子进程。
我希望它能有所帮助。问候。
You talked about a "command window", so I presume that the child is a console application.
In that case you can create the process in a separate conole and optionally force the new console to be iconified or hidden.
The following code launch a child process that interprets a batch file (mytest.bat).
I hope it can help. Regards.
听起来您希望子进程的输出显示在单独的窗口中。如果是这样,您需要调用
CreateProcess
并向其传递CREATE_NEW_CONSOLE
标志,而不是使用exec*
。It sounds like you want the child process's output to show up in a separate window. If so, you want to call
CreateProcess
and pass it theCREATE_NEW_CONSOLE
flag, rather than usingexec*
.