Link to home
Start Free TrialLog in
Avatar of fantasia123098
fantasia123098

asked on

Disabling [CRTL + ESC]

I have made a little client server program. The program is loaded as shell from system.ini.
I have made alittle dll to prevent users from pressing [CRTL + ESC] to start tasklist or an explorer. When I use this little dll it works fine as long as I not load the program as shell, but when I do I am not able to press on a main-menu or move scrollbars d:(
What is wrong and how can I solve this.

BTW I am using Delphi 4 Client / Server, and I want my program to work no matter if you are in win95 or win98 (no NT)
Thank in advance, Fantasia
Avatar of Madshi
Madshi

Can you please post the code of your little dll? Only thing that I can imagine is that there is something wrong with that.

If you don't use this dll, you can click at your mainmenu again, right?

Regards, Madshi.
How are you disabling [CRTL + ESC]?  I mean what method are you using
Avatar of fantasia123098

ASKER

4 Madshi (and heathprovost) this is the source code :
library ClientDll;

{$C FIXED PERMANENT PRELOAD}

uses
    WinProcs,
  SysUtils;
Const
     hHookCBT : THandle = 0;

function CBTHookFunc( nCode : Integer;
                      wparam : WParam;
                      lparam : LParam): LRESULT  stdCall;
begin
     if nCode=HCBT_SYSCOMMAND then begin
       MessageBeep(0);
       Result:=1; { removes message }
     end
     else
      { call next hook in chain }
      Result:=CallNextHookEx(hHookCBT, nCode, wParam, lParam);
end;

procedure InstallCBTHook; EXPORT;
var
  hLib : THandle;
  hProgMan : HWnd;
begin
  hLib:=GetModuleHandle('ClientDll');
  if (hHookCBT=0) then begin
    hProgMan:=FindWindow('Progman', NIL);
    hHookCBT:=SetWindowsHookEx(WH_CBT, @CBTHookFunc, hLib,
                               GetWindowThreadProcessId(hProgMan, nil));
  end;
end;

procedure RemoveCBTHook; EXPORT;
begin
  if (hHookCBT<>0) then begin
    UnhookWindowsHookEx(hHookCBT);
    hHookCBT:=0;
  end;
end;

EXPORTS
  InstallCBTHook,
  RemoveCBTHook;

end.

in the Main form´s OnCreate event i typed

"InstallCBTHook" and I remove when the machine restarts.

If I call the procedure "RemoveCBTHook" it works ok again, also if I don´t use the DLL then the mainmenus and scrollbars are just fine.  What is the problem, I think that I have made a mistake :)

Fantasia
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Madshi, Thank you for the good information, now I will try to fix this little Dll.
Is it ok if I post again if I can´t make it work?

Fantasia
Yes, of course...  :-)
4 Madshi.
Phew - I will never get this app to run :(
I can´t make it work, what am I doing wrong? Please Help
Hi fantasia,

try to use this CBTHookFunc in your dll:

function CBTHookFunc(nCode: integer; wparam: wParam; lparam: lParam) : LRESULT; stdCall;
begin
  if (nCode=HCBT_SYSCOMMAND) and
     ((wParam=SC_TASKLIST) or (wParam=SC_NEXTWINDOW) or (wParam=SC_PREVWINDOW)) then begin
    MessageBeep(0);
    result:=1; // removes message
  end else // call next hook in chain
    result:=CallNextHookEx(hHookCBT,nCode,wParam,lParam);
end;

If that doesn't work, please tell me WHAT does not work in detail. Then you'll probably have to wait two days. In the moment I've no free time at all. In 2 days I can test it for you...

Regards, Madshi.
Thank you Madshi, I will noe try to use it.
In the dll I made I did something like :
"case wParam of", but it did not work the right way.

Thans from Fantasia