Solved

Capture Alt-Ctrl-Del

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

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now