?
Solved

Workstation "Locked" -mode

Posted on 2004-04-21
15
Medium Priority
?
369 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:hakanfa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 2
15 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10885736
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
 

Author Comment

by:hakanfa
ID: 10890271
Hmm, well not sure of how to use it.. Anyway, how about Win NT 4.0?
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 2000 total points
ID: 10898124

   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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10898195
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
 

Author Comment

by:hakanfa
ID: 10898873
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
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10898908

  hakanfa did you checked my example - it is 100% working ...
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10899315
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
 

Author Comment

by:hakanfa
ID: 10899362
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
 

Author Comment

by:hakanfa
ID: 10899479
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
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10899534
http://files.delphi-si.com/lee/WinLogonPackage.zip

sorry about that :(
it's a crazy day
0
 

Author Comment

by:hakanfa
ID: 10901591
Increase points 900
0
 

Author Comment

by:hakanfa
ID: 10901726
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
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10907384
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
 

Author Comment

by:hakanfa
ID: 10907416
..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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question