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
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
How are you disabling [CRTL + ESC]? I mean what method are you using
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(hHo okCBT, nCode, wParam, lParam);
end;
procedure InstallCBTHook; EXPORT;
var
hLib : THandle;
hProgMan : HWnd;
begin
hLib:=GetModuleHandle('Cli entDll');
if (hHookCBT=0) then begin
hProgMan:=FindWindow('Prog man', NIL);
hHookCBT:=SetWindowsHookEx (WH_CBT, @CBTHookFunc, hLib,
GetWindowThreadProcessId(h ProgMan, nil));
end;
end;
procedure RemoveCBTHook; EXPORT;
begin
if (hHookCBT<>0) then begin
UnhookWindowsHookEx(hHookC BT);
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
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(hHo
end;
procedure InstallCBTHook; EXPORT;
var
hLib : THandle;
hProgMan : HWnd;
begin
hLib:=GetModuleHandle('Cli
if (hHookCBT=0) then begin
hProgMan:=FindWindow('Prog
hHookCBT:=SetWindowsHookEx
GetWindowThreadProcessId(h
end;
end;
procedure RemoveCBTHook; EXPORT;
begin
if (hHookCBT<>0) then begin
UnhookWindowsHookEx(hHookC
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Is it ok if I post again if I can´t make it work?
Fantasia
Yes, of course... :-)
ASKER
4 Madshi.
Phew - I will never get this app to run :(
I can´t make it work, what am I doing wrong? Please Help
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(hHo okCBT,nCod e,wParam,l Param);
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.
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(hHo
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.
ASKER
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
In the dll I made I did something like :
"case wParam of", but it did not work the right way.
Thans from Fantasia
If you don't use this dll, you can click at your mainmenu again, right?
Regards, Madshi.