

My standard Windows installation yields to the following list of windowStation:Desktop:dskHandle I then open the desktops using OpenDesktop and store the handle to the desktop.
#Make screensaver start immediately how to#
but that's not the nice way.Įdited: obviously the problem is related to the GetDesktopWindow() call, still i don't know how to fix thatĪccording to Erics suggestion, i do now iterate all window station (using OpenWindowStation), then for all of those i iterate all desktops (using EnumDesktops). I could implement a small program that runs in the user session, which is triggered by the service to trigger the screensaver. Which does not have access to the User's session. ServiceProcessInstaller.Account = ServiceAccount.LocalSystem This doesn't work and i think the reason is that the service is installed with the If (changeDescription.Reason = SessionChangeReason.SessionLock) want to start the screensaver as soon as the session is locked (just for prove of concept), i could try protected override void OnSessionChange(SessionChangeDescription changeDescription) My problem is that i want to start the screensaver out of a system service. SendMessage(hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, new IntPtr(0)) IntPtr SC_SCREENSAVE = new IntPtr(0xf140) Private static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam) Private static extern IntPtr GetDesktopWindow() I have several variants to start the screensaver.
