1

This is a toughie (I am obviously new to Stack Overflow)! Delphi code for displaying an alert (reminder) to sign out when a user locks their PC. I believe this would need:

  1. Detect locking their Windows 7 or 10 computer / workstation.

  2. Display a MessageDlg with 2 buttons: "Lock" (proceed with locking computer) and "Cancel Lock" (so that they can sign out online and then lock their computer).

This could possibly be an executable installed on their local computer that would run on StartUp in the background.

Please note, I have created simple Delphi programs in Delphi 6 for years but this is way above my "pay grade". If this is even possible MANY thanks for your time !! You cannot begin to imagine how helpful this would be!

Scott

I tried copying "How Do I detect a user locking / unlocking a screen in Windows 7". It did not have the lock cancelling feature that would allow a user to perform another task before locking their computer.

ScottMan
  • 11
  • 2
  • 1
    I don't think a lock cancelling feature is needed. The user himself has chosen to log off. So just obey, and log off. No magic there. If however you wish to annoy users with yet another nagging dialog, you could check this https://stackoverflow.com/questions/25536216/delphi-prevent-application-shutdown. That should provide you with what you need. – Sherlock70 Oct 25 '22 at 14:38
  • He does not want to cancel a log off but cancel locking the computer. And he as a good reason for that. – dummzeuch Oct 25 '22 at 15:47
  • It is possible to detect when the computer has *already been* locked (ie, by catching [`WM_WTSSESSION_CHANGE`](https://learn.microsoft.com/en-us/windows/win32/termserv/wm-wtssession-change)), but AFAIK it is not possible to detect when the computer is *being requested* to lock, nor is it possible to block the locking. So, I agree with Sherlock70, just handle the case that the computer is already locked and signout as needed. – Remy Lebeau Oct 25 '22 at 16:11
  • Whatever you are trying to do, it isn't the solution to any problem – David Heffernan Oct 25 '22 at 18:03
  • Welcome to the internet - it works through links. Please link to the website you're referring to in your text instead of only putting text into quotation marks. Also note that closing a notebook/laptop mostly implies locking the desktop - how would you expect to interfere with that? – AmigoJack Oct 25 '22 at 18:23
  • One way could be to have really long times for locking. Then write a program that is running all the time. It attempts a lock based on whatever criteria you have. Before it does, it shows the dialog you desire. This post shows [How do I lock a windows workstation programmatically](https://stackoverflow.com/questions/13745788/how-do-i-lock-a-windows-workstation-programmatically) – Rohit Gupta Oct 26 '22 at 10:47
  • Thanks everyone for your input !! I have a web based attendance board. Some companies are having issues trying to get their employees to remember to sign out. Was trying to make an alert popup to remind them to sign out when they lock their computer. Thanks again! – ScottMan Oct 26 '22 at 12:50

1 Answers1

-2

As far as I know it is not possible to prevent user from locking the computer. In fact it is quite common practice to have computers set up in a way so that they lock themselves automatically after certain time of user inactivity.

This can greatly improves overall IT security as in most cases prevents random person getting access to unlocked computer just because person that is otherwise using this computer stepped away for a few minutes.

Now if your program would somehow prevent this from happening you would be potentially compromising IT security.

In fact I suspect that you might want to actually increase IT security by forcing your users to regularly log out of the online system. But this is not the way to do it.

It would be much better if your online service would use time limited session management. What I mean by this? I mean that online service session should time-out after user hasn't performed any activity in this online service for certain time.

SilverWarior
  • 7,372
  • 2
  • 16
  • 22
  • Did not downvote, but this "_user inactivity_" and "_stepped away_" rubbish is a nightmare on work and when doing online banking. The argumentation ignores times when I simply read/analyze on the screen where no input is needed. Let alone the fact that my workspace is not exposed to others. At least I found ways to deal with such ridiculously forced settings. – AmigoJack Oct 25 '22 at 18:19
  • 1
    Only the 1st sentence of this answer is relevant to the OP's question, the rest is just ranting. – Remy Lebeau Oct 26 '22 at 00:39
  • Thank you so much for your input. I have a web based attendance board. Some companies are having issues trying to get their employees to remember to sign out. Was trying to make an alert popup to remind them to sign out when they lock their computer. Thanks again! – ScottMan Oct 26 '22 at 12:49