Solved

Capture Alt-Ctrl-Del

Posted on 2002-04-21
16
1,054 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
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!

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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