Solved

Workstation "Locked" -mode

Posted on 2004-04-21
15
357 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
  • 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 500 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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
 

Author Comment

by:hakanfa
ID: 10908248
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

832 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