Will,
The following code works on WinNT (4 and 2000), but not on Win9x.
Just create a new project, add a timer to the form, set the timer interval
to, say, 1000, and add this code to the form to test:
-------------------------start of code---------------------------------
'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:
'-Don Bradner, Arcata, California
Option Explicit
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
Dim templong As Long
' 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
Private Sub Timer1_Timer()
Debug.Print "NT screen saver is running: " & NTSaverRunning
End Sub
-------------------------end of code---------------------------------
Cheers,
Martin Pot
Email: martin.pot@h...
> -----Original Message-----
> From: Will [SMTP:w@h...]
> Sent: Saturday, December 09, 2000 5:07 AM
> To: professional vb
> Subject: [pro_vb] Is screen Saver On?
>
> Is there a way to tell if a screen saver is on? I thought there was a
> WinAPI
> call but I can't find anything on it.
>
> Will