Solved

Workstation "Locked" -mode

Posted on 2004-04-21
15
353 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now