devxlogo

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

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Seven Service Boundary Mistakes That Create Technical Debt

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.