Solved

Capture Alt-Ctrl-Del

Posted on 2002-04-21
16
1,048 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
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

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 100 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

839 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