devxlogo

Is the NT Screen Saver Running?

Is the NT Screen Saver Running?

Use this code to determine whether NT is running on its screen saver desktop. NT5 has an SPI function, but this code should work on any NT version:

 Private Declare Function OpenDesktop& Lib "user32" Alias _	"OpenDesktopA" (ByVal lpszDesktop$, ByVal dwFlags$, _	ByVal fInherit&, ByVal dwDesiredAccess&) Private Declare Function CloseDesktop& Lib "user32" _	(ByVal hDesktop&)Public Function NTSaverRunning() As Boolean	Dim hDesktop As Long	Const MAXIMUM_ALLOWED = &H2000000	If winOS  WinNT Then	'Make your OS determination elsewhere		NTSaverRunning = False		Exit Function	End If	NTSaverRunning = False	hDesktop = OpenDesktop("screen-saver", 0&, 0&, _		MAXIMUM_ALLOWED)	If hDesktop = 0 Then		If Err.LastDllError = 5 Then			NTSaverRunning = True		End If	Else		Templong = CloseDesktop(hDesktop)		NTSaverRunning = True	End IfEnd Function

devx-admin

Share the Post: