Windows XP 屏幕保护程序 - 使用屏幕保护程序启动进程死机 [英] Windows XP Screen Saver - Launched Process Dies with Screen Saver

查看:43
本文介绍了Windows XP 屏幕保护程序 - 使用屏幕保护程序启动进程死机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一些运行 Windows XP 的信息亭构建一个相当专业的屏幕保护程序应用程序.用户往往会在不将浏览器返回主页的情况下离开信息亭,因此屏幕保护程序会执行以下操作:

I'm building a rather specialized screen saver application for some kiosks running Windows XP. Users tend to leave the kiosks without returning the browser to the homepage, so the screen saver does the following:

  1. 通过标准屏幕保护机制启动
  2. 通知用户最近没有活动,浏览器将在 X 秒后关闭.
  3. 如果 X 秒后没有用户活动,屏幕保护程序会终止所有当前浏览器实例(通过 Process.GetProcessesByName)并启动一个新的浏览器实例,该实例指向已配置的网站(通过 Process.Start).
  4. 然后屏幕变黑",直到用户移动鼠标或按下某个键 - 此时屏幕保护程序退出.

当它在 Windows Vista 或 2008 上运行时,一切都按预期运行.

When this runs on Windows Vista or 2008, everything works as expected.

但是,在 Windows XP(即自助服务终端运行的系统)上,当屏幕保护程序退出时,浏览器进程会被终止.如果我在屏幕保护程序存在之前添加一个 Thread.Sleep,我可以看到浏览器并与浏览器交互,直到屏幕保护程序退出.

However, on Windows XP (which is what the kiosks are running), when the screen saver application exits, the browser process is killed. If I add a Thread.Sleep just before the screen saver exists, I can see and interact with the browser up until the point at which the screen saver exits.

更令人困惑的是,当我通过单击设置区域中的预览"按钮运行屏幕保护程序时,Windows XP 不会表现出这种行为 - 也就是说,它的行为符合预期.在这种情况下运行完全相同的代码.

To make matters more confusing, Windows XP does NOT exhibit this behavior when I run the screen saver by clicking the "Preview" button in the settings area - that is, it behaves as expected. The exact same code is run in this case.

我在 .NET 2.0 框架下测试了这个,后来安装了 .NET 2.0 SP1.在 Windows 2008 工作站上,我有 3.5 SP1.

I tested this under the .NET 2.0 framework, and later installed .NET 2.0 SP1. On the Windows 2008 workstation, I have 3.5 SP1.

这些 .NET 版本在对已启动进程的依赖性方面是否存在一些差异?是否可以设置一些标志以确保启动的浏览器进程没有附加"到屏幕保护程序应用程序?

Is there some difference between these versions of .NET with respect to dependencies on launched processes? Is there some flag I can set to make sure that the launched browser process is not "attached" to the screen saver application?

推荐答案

有一些 代码在 CodeProject 中包装了 Windows 桌面 API.它包括在不同桌面中打开新进程的功能,如果不直接使用,您至少可以查看.(基本上,Windows API CreateProcess 函数有一个参数,允许您指定在哪个桌面上启动进程.)

There's some code at CodeProject that wraps the Windows Desktop API. It includes a function to open a new process in a different desktop that you might at least be able to look at if not use directly. (Basically there's a parameter to the Windows API CreateProcess function that allows you to specify which desktop to start the process on.)

如果这不起作用,您也可以尝试我的回答到您的另一个问题(关于使用 SendMessage 进程间获取除屏幕保护程序之外的另一个进程来实际启动).这不是流程树问题的最佳答案,但如果流程树不是问题,它可能确实有效.

If that doesn't work you might also try out my answer to your other question (about using SendMessage inter-process to get another process besides the screen saver process to actually do the launching). It's not the best answer to the process tree issue, but it might actually work if the process tree is not the problem.

这篇关于Windows XP 屏幕保护程序 - 使用屏幕保护程序启动进程死机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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