Passworded screensaver

Blitz3D Forums/Blitz3D Programming/Passworded screensaver

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The password dialogue is done by Windows, isn't it?
On 2K, XP and NT (I think), then yes, but it's the responsibility of the screen saver on 9x.


@Graythe - Try running this and let your saver start (wont work for a preview)...
; user32.decl
;------------------
; .lib "user32.dll"
; SystemParametersInfo(uAction%, uParam%, lpvParam*, fuWinIni%) : "SystemParametersInfoA"
; MessageBeep(wType%)
;------------------

; Should work on 9x, 2K and XP

Const SPI_GETSCREENSAVERRUNNING = $72

Local time = MilliSecs()
Local bnk = CreateBank(1)

Repeat
    If (MilliSecs() - time) >= 1000
        If SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, bnk, 0)
            If PeekByte(bnk, 0) Then MessageBeep(-1)
        EndIf
        time = MilliSecs()
    EndIf
    
    Delay 10
Until KeyHit(1)

End
Here's a more fully featured version I have. Written for BMax, but should be easy enough to convert...
'Conversion of some C source I found on the net.
' Should work on 9x, 2K, XP and NT

Extern "win32"
    Function GetLastError()
    Function SystemParametersInfo(uiAction, uiParam, pvParam Var, fWinIni) = "SystemParametersInfoA@16"
    Function OpenDesktop(lpszDesktop$z, dwFlags, fInherit, dwDesiredAccess) = "OpenDesktopA@16"
    Function CloseDesktop(hDesktop)
End Extern

Const ERROR_ACCESS_DENIED = $5
Const SPI_GETSCREENSAVERRUNNING = $72
Const MAXIMUM_ALLOWED = $2000000

Function SaverIsRunning()
    Local running = False
        
    If SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, running, 0)
        If running Then Return True
    EndIf
        
    Local hDesk = OpenDesktop("screen-saver", 0, False, MAXIMUM_ALLOWED)
    If hDesk
        CloseDesktop(hDesk)
        Return True
    EndIf
    
    If GetLastError() = ERROR_ACCESS_DENIED Then Return True
End Function