启动和停止屏幕保护程序
我想应该很简单。我想强制电脑进入屏幕保护模式,并在我通过 D2006) 应用程序签入的条件满足时退出它。它似乎不起作用:
if ScreenSaverExitRequested then
begin
SystemParametersInfoResult := SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, @ScreenSaverIsRunning, 0);
if ScreenSaverIsRunning then
begin
SystemParametersInfoResult := SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, UINT(false), nil, SPIF_SENDWININICHANGE);
end ;
end ;
....
if ScreenSaverEntryRequested then
begin
SystemParametersInfoResult := SystemParametersInfo (SPI_SETSCREENSAVEACTIVE, 1, nil, SPIF_SENDWININICHANGE) ;
end ;
SystemParametersInfoResult 在每种情况下都返回 true。对 SystemParametersInfo 的调用似乎没有任何效果。如果我使用“控制面板显示属性”对话框上的“预览”按钮将 PC 置于 SS 模式,则执行我的代码不会执行任何操作。
Should have been simple I would have thought. I want to force the PC to go into screen saver mode, and exit it when conditions I am checking in by D2006) app come true. It doesn't seem to work:
if ScreenSaverExitRequested then
begin
SystemParametersInfoResult := SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, @ScreenSaverIsRunning, 0);
if ScreenSaverIsRunning then
begin
SystemParametersInfoResult := SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, UINT(false), nil, SPIF_SENDWININICHANGE);
end ;
end ;
....
if ScreenSaverEntryRequested then
begin
SystemParametersInfoResult := SystemParametersInfo (SPI_SETSCREENSAVEACTIVE, 1, nil, SPIF_SENDWININICHANGE) ;
end ;
SystemParametersInfoResult is returning true in each case. The calls to SystemParametersInfo don't seem to have any effect. If I place the PC in SS mode by using the "Preview" button on the Control Panel Display Properties dialog, executing my code does nothing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SPI_SETSCREENSAVEACTIVE 实际上并不启动/停止屏幕保护程序。它的目的是让实际的屏幕保护程序调用,让操作系统知道它们正在运行或退出。要启动屏幕保护程序,请尝试向 GetDesktopWindow() 窗口发送 WM_SYSCOMMAND/SC_SCREENSAVE 消息。
SPI_SETSCREENSAVEACTIVE does not actually start/stop the screensaver. It is meant for actual screensavers to call to let the OS know that they are running or exiting. To start the screensaver, try sending a WM_SYSCOMMAND/SC_SCREENSAVE message to the GetDesktopWindow() window.