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
See also  Small Business Strategies with Venmo

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist