Solved

Disable Windows key ?

Posted on 2004-04-21
15
1,194 Views
Last Modified: 2012-05-04
Iwant Delphi code To disable Win Key ? I founded one in this page But Icouldnot use it
http://www.swissdelphicenter.ch/torry/printcode.php?id=1212 help me please
0
Comment
Question by:Prof_MAM
15 Comments
 
LVL 3

Expert Comment

by:MikProg
ID: 10885809
It must be keyboard hook local to you program that catch
VK_LWIN      Left Windows key (Microsoft keyboard)
VK_RWIN      Right Windows key (Microsoft keyboard)
events and trash them
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10886357
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    Hook_Handle : THandle;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

function KeyboardProc(nCode, wParam, lParam : Integer) : Integer; stdcall;
var
  bControlKeyDown : Boolean;
begin
  bControlKeyDown := False;
  case nCode of
    HC_ACTION : begin
                  if (wParam = VK_LWIN) or (wParam = VK_RWIN) then
                    begin
                      Result := 1;
                      Exit;
                    end;
                end;
  end;
  Result := CallNextHookEx (Form1.Hook_Handle, nCode, wParam, lParam);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // Install hook
  Hook_Handle := SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, hInstance, 0);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  // DeInstall hook
  UnhookWindowsHookEx(Hook_Handle);
end;
0
 

Author Comment

by:Prof_MAM
ID: 10896928
It didn't Work Windows Key Is still working After pressing button1 Or button 2
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10898182

   Here is working example, I tested it
   
   http://www.swissdelphicenter.ch/torry/showcode.php?id=1212
0
 

Author Comment

by:Prof_MAM
ID: 10903570
I think it is the same code I have but I couldn't run it send it to me if you can And points are yours if it works
prof_mam1@hotmail.com
0
 

Author Comment

by:Prof_MAM
ID: 10908276
Ivanov_g where are you ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10908327

   Releasing version ... production tonight. I will go to your code when I have few minutes. Is it urgent
0
 

Author Comment

by:Prof_MAM
ID: 10910571
No take your time
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10916527

   If your application is like destop shield - there is very easy way :

procedure EnableFastTaskSwitching(Enable : boolean = True);
begin
  // If Enable is False, we must use True to disable,
  // If Enable is True, we must use False to enable
  SystemParametersInfo(SPI_SCREENSAVERRUNNING, cardinal(NOT Enable), nil, 0);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // Disable Win keys
  EnableFastTaskSwitching(False);
end;

   If not - you need the hook.
0
 

Author Comment

by:Prof_MAM
ID: 10921646
I am using win xp SystemParametersInfo() doesnot work on xp  I need the hook
0
 

Author Comment

by:Prof_MAM
ID: 10956788
where is the experts ??! no body Can do that ?
0
 
LVL 14

Expert Comment

by:Esopo
ID: 13281952
Just as a comment:

You can hook the keyboard. Don't know for sure if it will work with the Windows Key, but it's surely worth a try:
http://delphi.about.com/od/vclusing/l/aa101000a.htm
http://www.infojet.cz/program/delphi/tips/tip0003.html

Hook dll:
http://chithai.com/delphi/crazykeyboard.htm

I would love to post code for that but the last time I played with it I was younger, brighter and more versed ;)

Good luck.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13302449
PAQed with points refunded (140)

modulo
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 262
proper way to parse url in delphi 2 160
HTML text in the body of an email (delphi code) 12 95
QRReport  TQrmemo vertical stretching 1 42
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
A short film showing how OnPage and Connectwise integration works.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 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

22 Experts available now in Live!

Get 1:1 Help Now