Prof_MAM
asked on
Disable Windows key ?
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
http://www.swissdelphicenter.ch/torry/printcode.php?id=1212 help me please
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_KEYBOA RD, KeyboardProc, hInstance, 0);
end;
procedure TForm1.Button2Click(Sender : TObject);
begin
// DeInstall hook
UnhookWindowsHookEx(Hook_H andle);
end;
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
begin
// Install hook
Hook_Handle := SetWindowsHookEx(WH_KEYBOA
end;
procedure TForm1.Button2Click(Sender
begin
// DeInstall hook
UnhookWindowsHookEx(Hook_H
end;
ASKER
It didn't Work Windows Key Is still working After pressing button1 Or button 2
ASKER
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
prof_mam1@hotmail.com
ASKER
Ivanov_g where are you ?
Releasing version ... production tonight. I will go to your code when I have few minutes. Is it urgent
ASKER
No take your time
If your application is like destop shield - there is very easy way :
procedure EnableFastTaskSwitching(En
begin
// If Enable is False, we must use True to disable,
// If Enable is True, we must use False to enable
SystemParametersInfo(SPI_S
end;
procedure TForm1.Button1Click(Sender
begin
// Disable Win keys
EnableFastTaskSwitching(Fa
end;
If not - you need the hook.
ASKER
I am using win xp SystemParametersInfo() doesnot work on xp I need the hook
ASKER
where is the experts ??! no body Can do that ?
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
VK_LWIN Left Windows key (Microsoft keyboard)
VK_RWIN Right Windows key (Microsoft keyboard)
events and trash them