0

Am I missing something? I run the following code on my Vista laptop from a user-mode process:

BOOL bSecure = -100;
if(::SystemParametersInfo(SPI_GETSCREENSAVESECURE, NULL, &bSecure, 0))
{
    int success = 1;
}

The purpose is to obtain the "On resume, display logon screen" screensaver setting (circled in red below):

enter image description here

SystemParametersInfo succeeds but bSecure is not changed.

For those who may not believe me, here's the screenshot from the VS debugger:

enter image description here

Upon further debugging it turns out that SystemParametersInfo actually returns 0xC0000002 when on my other computer it returns 1 when it succeeds. I thought it is not supposed to return HRESULT, or is it?

Anyway, the question -- how to reliably obtain this setting?

c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • *If the function succeeds, the return value is a nonzero value.* - Nothing to do with `HRESULT`. You can't make the assumption it is one. FWIW, works fine on Windows 8.1. – chris Dec 11 '13 at 02:38
  • @chris: I know. It worked on 99% of other OS I tried this code on. – c00000fd Dec 11 '13 at 02:45

0 Answers0