Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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 If
End Function
Don Bradner
 
Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date