Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1084
  • Last Modified:

Capture Alt-Ctrl-Del

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
S_Warrior
Asked:
S_Warrior
  • 6
  • 4
  • 3
  • +3
1 Solution
 
ap800Commented:
Use the api function:SystemParamptersInfo,you can doload the http://www.dapha.net/soure/api/allapi.zipi3981KBj
Come from china.
0
 
S_WarriorAuthor Commented:
Can you please give me more detailed answer
0
 
KalrothCommented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
S_WarriorAuthor Commented:
Is there any function that works on Windows Nt/2000?
0
 
ap800Commented:
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
 
S_WarriorAuthor Commented:
So what is the assemble code for disabling the ALT-CTRL-DEL?
0
 
ap800Commented:
I am sorry,what's I know is very limit,you can search it on
other website
0
 
S_WarriorAuthor Commented:
That is not the answer, sorry
0
 
quantum2Commented:
Public
0
 
quantum2Commented:
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
 
S_WarriorAuthor Commented:
Sorry this dont work, its disabling the task manager but dont disable the ALT-CTRL-DEL.

its still showing the win2k dialog
0
 
quantum2Commented:
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
 
S_WarriorAuthor Commented:
And how can I write some thing to the system level?
0
 
OmycronCommented:
Listening...
0
 
quantum2Commented:
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
 
RastyCommented:
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 6
  • 4
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now