Microsoft KB Archive/318781

= BUG: SystemParametersInfo with SPI_GETSCREENSAVEACTIVE Always Returns True on Windows 2000 =

Article ID: 318781

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Windows 2000 Standard Edition

-



This article was previously published under Q318781



SYMPTOMS
The SystemParametersInfo function with the uiAction parameter set to SPI_GETSCREENSAVEACTIVE returns True although no screen saver is active.



RESOLUTION
You can work around this problem by querying the registry to check whether the screen saver is active. The presence of the Scrnsave.exe file under the registry key HKCU\Control Panel\Desktop indicates that the screen saver is active.

The following sample code demonstrates this condition: HKEY hKeySreenSaver = NULL; long lReturn = NULL; long lScreenSaver = NULL; DWORD dwData = NULL; lReturn = RegOpenKeyEx(HKEY_CURRENT_USER,           TEXT(&quot;Control Panel\\Desktop&quot;),            0,            KEY_QUERY_VALUE,            &hKeySreenSaver); if(lReturn == ERROR_SUCCESS)

{   lScreenSaver = RegQueryValueEx(hKeySreenSaver,                    TEXT(&quot;SCRNSAVE.EXE&quot;),                   NULL,                   NULL,                   NULL,                   &dwData);

if(lScreenSaver == ERROR_SUCCESS) MessageBox(NULL,               &quot;Screen Saver is Active&quot;,                &quot;Screen Saver&quot;,               MB_OK); else MessageBox(NULL,               &quot;Screen Saver is Not Active&quot;,                &quot;Screen Saver&quot;,               MB_OK); } RegCloseKey(hKeyScreenSaver); hKeyScreenSaver = NULL;



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Set the screen saver to None:

Click Start menu, point to Control Panel, double-click Display, click the Screen Saver tab, and then select None in the Screen Saver box.  Call SystemParametersInfo function with the uiAction parameter set to SPI_GETSCREENSAVEACTIVE. bool result = false; SystemParametersInfo(SPI_GETSCREENSAVEACTIVE,0,(LPVOID)&result,0); 

Note that the value of the result is set to True even though no screen saver is active.

Keywords: kbbug kbnofix KB318781

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.