Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Advanced
Apr 23, 1999



Application Security Testing: An Integral Part of DevOps

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&, _
	If hDesktop = 0 Then
		If Err.LastDllError = 5 Then
			NTSaverRunning = True
		End If
		Templong = CloseDesktop(hDesktop)
		NTSaverRunning = True
	End If
End Function
Don Bradner
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date