Workstation "Locked" -mode

Hello!

I need an example of a procedure that triggers everytime when the workstation enters/come off the locked mode.
I know that there is a lot of different methods with dll:s etc. which I've tried but wont get them working.

Need a full example with code how to get this done.

Yours,
Hokki
hakanfaAsked:
Who is Participating?
 
Ivanov_GConnect With a Mentor Commented:

   Here is the function which detects if the Workstation is locked:

  function IsWorkstationLocked: Boolean;
  var
    hDesktop: HDESK;
  begin
    Result := False;
    hDesktop := OpenDesktop('default', 0, False, DESKTOP_SWITCHDESKTOP);
    if hDesktop <> 0 then
      begin
        Result := not SwitchDesktop(hDesktop);
        CloseDesktop(hDesktop);
      end;
  end;

  You have to trigger this in Timer(see my example below) :

  procedure TForm1.Timer1Timer(Sender: TObject);
  var
    S : String;
  begin
    S := FormatDateTime('[dd.mm.yyyy hh:nn:ss] ', Now);
    if IsWorkstationLocked then
      S := S + 'Locked'
    else
      S := S + 'Unlocked';
    Memo1.Lines.Add(S);
  end;
0
 
Lee_NoverCommented:
for windows 2000 and newer you can use WinlogonNotification packages
I have an implementation here: http://files.delphi-si.com/WinLogonPackage.zip
to register for an event simply call (in wlgnImport.pas - also an example of the receiving part):
RegisterNotification(WLX_OnLock, WM_USERCHANGED_WLGN, Handle);
0
 
hakanfaAuthor Commented:
Hmm, well not sure of how to use it.. Anyway, how about Win NT 4.0?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Lee_NoverCommented:
copy the dll to your apps folder (prefered but you can copy it anywhere but if it's not in the syspath you need to specify the complete path to it)
I mentioned everything else :)
0
 
hakanfaAuthor Commented:
well Lee Nover, I'm not so familiar with this so can You please be more specific?
A complete snap of code from the client side would do it..I think it is not to much to
ask for 500 pts?

Hokki
0
 
Ivanov_GCommented:

  hakanfa did you checked my example - it is 100% working ...
0
 
Lee_NoverCommented:
sorry .. I've uploaded the new version with an example project

logon package registration requires a system reboot because it's loaded by the winlogon process

run the exe, click "register dll", reboot, run exe, click "register notification" then do some test .. lock/unlock the station
0
 
hakanfaAuthor Commented:
Hello Ivanov G, Your code is complete and IT WORKS! Simple and great, but I'm ready to increase my points
and split dem between You and Lee Nover if his code works too. But as I said if I can't get it working You will
get Your well earned points! Your code is great simple and with no extra dll:s!
0
 
hakanfaAuthor Commented:
Lee Nover, I downloaded the Your pack but it seems to be the same code I downloaded
yesterday is this link correct? http://files.delphi-si.com/WinLogonPackage.zip

 
0
 
Lee_NoverCommented:
http://files.delphi-si.com/lee/WinLogonPackage.zip

sorry about that :(
it's a crazy day
0
 
hakanfaAuthor Commented:
Increase points 900
0
 
hakanfaAuthor Commented:
Hello,
First of all I want to thank both of You for great support.
1.Ivanovs example did just what i was looking for. Simple without any
   complex dll:s. GREAT SOLUTION! Grade: A 500 pts

2.LE Novers solution is more complex and works great also. One problem
  though, it doesnt work under Win NT?? (Win 200 and XP = OK). A little bit
  complex with dll:s Grade A 400 pts

I dont know how to increase points (couldnt find any "Increase points" filed) and
therefore I'm asking the administrators to act as I wich.. I hope..

THANK YOU GUYS!
0
 
Lee_NoverCommented:
open a new question like 'points for Lee_Nover for Q_20962956' ;)

I needed something more than just locked/unlocked so I implemented a winlogon notification package
and I prefere the more 'advanced' methods ... you learn more ;-)
0
 
hakanfaAuthor Commented:
..will see what the administrators can do. I asked them to award you as described
in my last comment..Hope they do as I asked them to do. Will see, if not I'll post a new
question like you described

Hokki
0
 
hakanfaAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.