PowerBuilder – Timing Out a Windows Session
There are a variety of techniques to locking or timing out an application after a certain amount of inactivity. With earlier versions of Windows (XP and prior) a common approach was to invoke the screen saver via a Send command.
send(handle(This),274,61760,0)
This doesn’t work with Windows 7 (or Vista). Try the following:
integer li_rc
OleObject lole_wsh
lole_wsh = CREATE OleObject
li_rc = lole_wsh.ConnectToNewObject ( "WScript.Shell" )
IF li_rc > 0 THEN
lole_wsh.Run ("rundll32.exe user32.dll,LockWorkStation")
lole_wsh.DisconnectObject()
END IF
This can be used in Windows XP as well.