Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: SystemParametersInfo with SPI_GETSCREENSAVEACTIVE Always Returns True on Windows 2000


Symptoms

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

↑ Back to the top


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("Control Panel\\Desktop"),
0,
KEY_QUERY_VALUE,
&hKeySreenSaver);
if(lReturn == ERROR_SUCCESS)

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

if(lScreenSaver == ERROR_SUCCESS)
MessageBox(NULL,
"Screen Saver is Active",
"Screen Saver",
MB_OK);

else
MessageBox(NULL,
"Screen Saver is Not Active",
"Screen Saver",
MB_OK);

}
RegCloseKey(hKeyScreenSaver);
hKeyScreenSaver = NULL;

↑ Back to the top


Status

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

↑ Back to the top


More Information

Steps to Reproduce the Behavior

  1. 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.
  2. 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.

↑ Back to the top


Keywords: kbbug, kbdsupport, kbnofix, kb

↑ Back to the top

Article Info
Article ID : 318781
Revision : 1
Created on : 1/7/2017
Published on : 6/19/2014
Exists online : False
Views : 1406