?
Solved

Capture Alt-Ctrl-Del

Posted on 2002-04-21
16
Medium Priority
?
1,071 Views
Last Modified: 2012-05-04
Hello.


How can I hook Alt-Ctrl-Del on my application so if I Click Alt-Ctrl-Del it will go to my function and not do the windows command?
0
Comment
Question by:S_Warrior
[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
  • 6
  • 4
  • 3
  • +3
16 Comments
 

Expert Comment

by:ap800
ID: 6957769
Use the api function:SystemParamptersInfo,you can doload the http://www.dapha.net/soure/api/allapi.zipi3981KBj
Come from china.
0
 

Author Comment

by:S_Warrior
ID: 6959030
Can you please give me more detailed answer
0
 
LVL 2

Expert Comment

by:Kalroth
ID: 6961176
Well I can't give you an complete answer, as this function only works on Windows 95/98/ME .. but I guess it's better than nothing :-)

-- CODE SNIPPIT --

function DisableCAD(State : Boolean): LongBool;
const
  SPI_SETSCREENSAVERRUNNING = 97;
var
  Dummy : LongInt;
begin
  result := SystemParametersInfo(SPI_SETSCREENSAVERRUNNING,Word(State),@Dummy,0);
end;

-- CODE SNIPPIT --
0
Technology Partners: 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!

 

Author Comment

by:S_Warrior
ID: 6962025
Is there any function that works on Windows Nt/2000?
0
 

Expert Comment

by:ap800
ID: 6967988
The Ctrl+Alt+Del was very high in the nt/2k,so the SystemParametersInfo Only use in the 98/me.You can use the assemble .It's say that the Ctrl+Alt+Del can't use int the nt/2k
0
 

Author Comment

by:S_Warrior
ID: 6968244
So what is the assemble code for disabling the ALT-CTRL-DEL?
0
 

Expert Comment

by:ap800
ID: 6972985
I am sorry,what's I know is very limit,you can search it on
other website
0
 

Author Comment

by:S_Warrior
ID: 6974615
That is not the answer, sorry
0
 
LVL 1

Expert Comment

by:quantum2
ID: 6981400
Public
0
 
LVL 1

Expert Comment

by:quantum2
ID: 6981507
you may have already tried an OnKeyDown event handler, but Windows will already have dealt with the keypress. Your solution is to use the SystemParameterInfo Windows API function. This function can be used for a variety of purposes, including programmatically triggering screen savers, changing the desktop wallpaper, etcetera. In this situation, we will use it to fool Windows into believing that the screen saver is running, which will effectively disable the Ctrl-Alt-Tab keypress (as well as the Alt-Tab and Ctrl-Esc keypresses).

First, declare the following as a global variable or, better yet, a property of your form class:

   OldValue : LongBool;
This will be passed as a parameter to SystemParameterInfo.
Now, wherever you want to disable task switching, use this:

   SystemParametersInfo(97, Word(True), @OldValue, 0);
To re-enable task switching (and I strongly advise that you do this before you exit your Delphi app!), use this:
   SystemParametersInfo(97, Word(False), @OldValue, 0);
CAVEAT: This technique will work under Windows 3.x and Windows 95, but not under Windows NT!

The only way I know how to do this in NT is the following:

Create a system level keyboard hook and watch for that keypress event. Then do not allow the passing of that event to the system but respond instead to the event. I have done something like this in a DLL where I export the function to my app and process the system wide hook information and then decide to pass it or not to the desired application/OS.

Or, you can simply turn off the task manager alltogether as seen in the following code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Registry;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure DisableTaskManager(Const State: Boolean);
Var
Reg: TRegistry;
begin
Reg:=TRegistry.Create;
Try
        Reg.RootKey:=HKEY_CURRENT_USER;
        if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Policies\System', True)
        then
        Reg.WriteInteger('DisableTaskMgr',Integer(state));
        finally
        Reg.CloseKey;
        Reg.Free;
end
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caNone;
Form1.hide;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
DisableTaskManager(True);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
DisableTaskManager(False);
end;

end.
0
 

Author Comment

by:S_Warrior
ID: 6982847
Sorry this dont work, its disabling the task manager but dont disable the ALT-CTRL-DEL.

its still showing the win2k dialog
0
 
LVL 1

Expert Comment

by:quantum2
ID: 6985094
As I mentioned,
The only other way I would know how to do this is to trap all keys from the keyboard via a system level kboard hook, and then evaluate the sequence. If it is CTRL+ALT+DEL then you could have an event fire, else the keyboard output is passed through to the receiving application.

I know of no other way to accomplish what you are after at a system level other than this. Obviously it is easier at the application level.

Q2
0
 

Author Comment

by:S_Warrior
ID: 6985273
And how can I write some thing to the system level?
0
 
LVL 1

Expert Comment

by:Omycron
ID: 6985587
Listening...
0
 
LVL 1

Accepted Solution

by:
quantum2 earned 400 total points
ID: 6989473
Ok this is a different question.
In order to do this, you have to write a system level keyboard hook. Then you can trap everything. Being that this is a global system level hook, it is called from a DLL rather than your application, or it can run as a process.

From this, you monitor every key stroke and respond the ones you are looking for without passing the stroke to the parent application.

I will see what I can provide for you this weekend....

Q2
0
 

Expert Comment

by:Rasty
ID: 7822915
system level keyboard hooks will not help on NT/2000,
but it's possible with <a href="http://www.meliorasoft.com/kits/">KeyboardControl SDK</a>
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

771 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