简体   繁体   English

屏幕保护程序无法在Windows XP中启动外部程序

[英]Screensaver fails to launch external program in Windows XP

I'm writing a screensaver in C# which should launch an application and then terminate when the user presses the "A" key. 我正在用C#编写一个屏幕保护程序,该程序应启动一个应用程序,然后在用户按下“ A”键时终止。

This currently does happen on Windows 7 when you double click the .scr file or wait until it launches. 当您双击.scr文件或等待其启动时,当前在Windows 7上会发生这种情况。 On Windows XP the external application launches normally only when you double click the .scr file. 在Windows XP上,只有双击.scr文件,外部应用程序才能正常启动。 When the screensaver is launched by the OS, then pressing "A" does terminate the screensaver but the external application is launched momentarily then closes. 当操作系统启动屏幕保护程序时,按“ A”按钮会终止屏幕保护程序,但外部应用程序会立即启动,然后关闭。 The Task Manager shows that the external application closes a split second before the Screensaverso I would imagine that this terminates the external application too for some reason. 任务管理器显示外部应用程序在屏幕保护程序之前关闭了一秒钟,因此我可以想象这也由于某种原因终止了外部应用程序。 This is the behaviour with whatever you set the external application to be. 无论您将外部应用程序设置为什么,这都是这种行为。

Is there something internal that happens when a Screensaver is launched from the OS rather than double clicked by the user? 从操作系统启动屏幕保护程序,而不是由用户双击屏幕时,是否会发生内部变化?

I'm using System.Diagnostics.Process.Start() to run the external application but using Process and ProcessStartInfo has the same effect. 我正在使用System.Diagnostics.Process.Start()运行外部应用程序,但使用ProcessProcessStartInfo具有相同的效果。

I'm using .NET Framework 3.5 我正在使用.NET Framework 3.5

Regards, Frank 问候,弗兰克

Yes, a screen saver runs in its own desktop. 是的,屏幕保护程序可以在自己的桌面上运行。 There are three common ones, the login desktop, the one you are looking at now and the screen saver desktop. 共有三种常见的登录桌面,即您正在查看的登录桌面和屏幕保护程序桌面。 A process is associated to a desktop through the STARTUPINFO.lpDesktop member passed to CreateProcess. 进程通过传递给CreateProcess的STARTUPINFO.lpDesktop成员与桌面相关联。 When NULL, it runs in the current desktop. 为NULL时,它将在当前桌面上运行。

a desktop cannot be closed until all processes that run on it are closed. 在关闭桌面上运行的所有进程之前,无法关闭桌面。 Which is what you see happening done automatically. 您所看到的是自动完成的。 Not sure why you are trying to do this but you're looking at pinvoking CreateProcess to avoid getting this process killed. 不知道为什么要尝试执行此操作,但是您正在查看如何调用CreateProcess以避免该进程被杀死。 I do rather doubt that Windows allows this, screen savers were a notorious vector for malware. 我确实怀疑Windows是否允许这样做,屏幕保护程序是恶意软件的恶名昭著的载体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM