创建隐藏的进程(窗口不可见) [英] Creating hidden processes (window not visible)

查看:256
本文介绍了创建隐藏的进程(窗口不可见)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的CreateProcess()设置为STARTF_USESHOWWINDOW和SW_HIDE开始在其窗口隐藏在后台的应用程序的启动标志。
我这样做是为了运行计划的维护任务,我不希望有窗被人打扰。

在大多数情况下,窗口被隐藏,但在有些情况下程序的窗口弹出右出在你的面前(例如谷歌的Chrome的情况下 - 我开始用不同的应用程序测试,看看这是否是一次时间问题,但没了.. )。

这发生在Windows XP中少,但它发生了很多Vista的。

有没有办法,我缺少一个标志?是否有任何其他的方式与它的窗口隐藏,以创建一个过程?

谢谢!

我的样本code是:

 的char * ProgramName中
STARTUPINFO StartupInfoF;
PROCESS_INFORMATION ProcessInfoF;memset的(安培; StartupInfoF,0,sizeof的(StartupInfoF));
memset的(安培; ProcessInfoF,0,sizeof的(ProcessInfoF));StartupInfoF.cb = sizeof的(StartupInfoF);
StartupInfoF.wShowWindow = SW_HIDE;
StartupInfoF.dwFlags = STARTF_USESHOWWINDOW;如果(的CreateProcess(ProgramName中,
                  ,
                  0,
                  0,
                  假,
                  DETACHED_PROCESS,
                  0,
                  0,
                  &安培; StartupInfoF,
                  &安培; ProcessInfoF)== FALSE)
{
  //错误
}
其他
{
  // 好
}


解决方案

您可以在另一个桌面上启动的过程中,使用传递给CreateProcess的STARTUPINFO结构的lpDesktop成员。这样,过程中会有显示所有窗口,但另一个桌面上,让您(或您的用户)将不会被它困扰。

我从来没有与多个桌面工作,所以我不能说什么是副作用,但我认为这是可行的。通过查看 CreateDesktop 启动和向前移动。

I'm using CreateProcess() with startup flags set to STARTF_USESHOWWINDOW and SW_HIDE to start an application in the background with its window hidden. I'm doing this to run a scheduled maintenance tasks and i don't want to be bothered with windows.

In most cases the windows are hidden but there are cases where the program's window pops right out in front of you (for example Google's Chrome - i started testing with different apps to see whether this was a once time problem but nope...).

This happens less in Windows XP, but it happens a lot on Vista.

Is there a flag that I am missing? Is there any other way to create a process with its window hidden?

Thanks!

my sample code is:

char *ProgramName  
STARTUPINFO StartupInfoF;
PROCESS_INFORMATION ProcessInfoF;

memset(&StartupInfoF, 0, sizeof(StartupInfoF));
memset(&ProcessInfoF, 0, sizeof(ProcessInfoF));

StartupInfoF.cb = sizeof(StartupInfoF);
StartupInfoF.wShowWindow = SW_HIDE;
StartupInfoF.dwFlags = STARTF_USESHOWWINDOW;    

if (CreateProcess(ProgramName,
                  "",                 
                  0,
                  0,
                  FALSE,
                  DETACHED_PROCESS,
                  0,
                  0,                              
                  &StartupInfoF,
                  &ProcessInfoF) == FALSE)
{
  // error
}
else
{
  // OK
}

解决方案

You can start the process on another desktop, using the lpDesktop member of the STARTUPINFO structure passed to CreateProcess. This way the process will have all its windows shown, but on another desktop, so you (or your users) won't be bothered with it.

I've never worked with multiple desktops so I can't say what would be the side effects, but I think it's doable. Start by looking into CreateDesktop and move onward.

这篇关于创建隐藏的进程(窗口不可见)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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