views:

47

answers:

1

I'm having a problem with the SystemParametersInfo API in C#. I have no problem getting the screensaver timeout, but when I try to get the state of the "On resume display logon screen" checkbox I always get false.

[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref uint pvParam, uint fWinIni);

public void Test() {
    uint result = 0;
    SystemParametersInfo(76, 0, ref result, 0);
}

The result will always be 0, however I do see the registry value changing from 1 to 0 (but I can't use the registry value, because setting it via the registry would cause my new setting to be processed only after logoff).

You can use the value 14 to retrieve the screensaver timeout value.

I have already tried to rewrite the external function from a ref uint to a ref bool, but that doesn't matter.

I'm using Windows 7 x64. MSDN is my source for the parameter information:
http://msdn.microsoft.com/en-us/library/ms724947(VS.85).asp

Does anyone have a clue?

+2  A: 

SPI_GETSCREENSAVESECURE is 0x76, not 76.

Hans Passant
Ahhh and therefor 118, whoooops! Thnx!
Zyphrax