SetSuspendState() hangs up, why?

265 views Asked by At

I was wondering why the following happens?

I need to log off users and then put computer to sleep. I do the following (C++/WinAPI):

(Calling the following from the local system service):

WTSLogoffSession(WTS_CURRENT_SERVER_HANDLE, dwUserSessionID, TRUE);
SetSuspendState(FALSE, TRUE, FALSE);

But when I run this code on Windows Vista, SetSuspendState() hangs up and never returns. At the same time the system does not enter sleep mode either.

0

There are 0 answers