power schemes bug

Power schemes bug?

I have the following code to set the password prompt after suspend, which has been working fine in XP, but in Vista the SetActivePwrScheme() call causes the current power scheme settings to reset to defaults. Is this a bug, or has something changed?
BOOL PasswordPromptAfterSuspend(BOOL fEnable) { GLOBAL_POWER_POLICY sGlobalPwrPolicy; BOOL fResult = false;
if(CanUserWritePwrScheme()) { if(ReadGlobalPwrPolicy(&sGlobalPwrPolicy)) { if(fEnable) sGlobalPwrPolicy.user.GlobalFlags |= EnablePasswordLogon; else sGlobalPwrPolicy.user.GlobalFlags &= ~EnablePasswordLogon;
if(WriteGlobalPwrPolicy(&sGlobalPwrPolicy)) { UINT uActivePwrScheme; if(GetActivePwrScheme(&uActivePwrScheme)) fResult = SetActivePwrScheme(uActivePwrScheme, NULL, NULL); } } } return fResult; }
-- Thanks, Robert Tonsing

Windows Vista

Topic:


Nick: