Disable Keyboard and Mouse which Ctrl+Alt+Del can not Enable them.

Hi

I want to disable keyboard and mouse to avoid a user from using a client, and enable them when the server wants.

I can use BlockInput function from USER32.DLL  but there is a problem. user can easily enable them with pressing Ctrl+Alt+Del , even I deactivate Task Manager (in registry).

I want limit the user not to enable client in any way, untill server allow him/her.


here is my code:
---------------------------------------------------
procedure BlockInput(ABlockInput : boolean); stdcall; external 'USER32.DLL';

procedure TForm1.Button1Click(Sender: TObject);
begin
  BlockInput(True);
  Sleep(5000);
  BlockInput(False);
end;
---------------------------------------------------


and I deactivate Task Manager with modifying this value in registry
---------------------------------------------------
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr = 1
---------------------------------------------------


Thank you for your help.
mehdi_m.
mehdi_mAsked:
Who is Participating?
 
robert_marquardtConnect With a Mentor Commented:
It is impossible without a driver which i do not know how to write.
This is the area of remote admin tools.

What do you want to do? From the little bit of information available here i would guess that the basic design is completely flawed.
You want to use Windows which is a multitask OS as a monotask kiosk box.
Windows is specifically designed to not allow blocking of input precisely to always allow to switch tasks.
0
 
robert_marquardtCommented:
Stay away from such idiotic ideas. If your program crashes then the computer becomes unusable.
Your example is also of the worst kind. By sleeping the program does nothing anyway.

How about placing an OnMessage event filter which removes all mouse and keyboard input for your application only?
0
 
mehdi_mAuthor Commented:
Sleeping is a sample and I don't use it in my application. I just Lock/Unlock the client program with the server program. Even my program crashes, a restart will be OK.

I want the windows to be locked, in any way. Can you tell me how to use messages to do that, please?  Is it usefull? And aslo does the client program or the whole windows will be locked, with this method?

thank you.
mehdi_m
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
robert_marquardtCommented:
Of course only the client locks. It simply ignores all input.
Blocking the input of all processes is completely idiotic.
It can also only be done reliably with drivers.

What do you really want to do? A remote admin tool?
If you only want a thin client computerr then use an OS which can be configuerd for that like Linux.
0
 
mehdi_mAuthor Commented:
I have a client-server program ,of course they do many things else. and I want to add the capability of lock/unlock the clients from server too.

I will be glad if you can help me with message handling.

thank you.
mehdi_m
0
 
robert_marquardtCommented:
So where is the problem? The server sends a command to the client to stop handling user input.
This is something local to the client and should not affect other processes or the OS.

Have a look at the Application.OnMessage event. All keyboard (WM_KEYDOWN and WM_KEYUP) and mouse messages pass through this event.
There you simply mark the message as already handled and that is all.
0
 
mehdi_mAuthor Commented:
But it just disables messages that pass through the Client application form only. and not the whole windows.

I want to limit the user to from using the whole computer, not only from my little client program. Can you give me an example please!!?

mehdi_m
0
 
Slick812Commented:
I agree with robert, I do not beleive that your idea (as you so far have described) is any good, and you will have a difficult time doing that, and I beleive that a computer user should have the control of their computer, not some mindless software, I beleive I would just show a warning Form, saying -

WAIT, server is processing data
0
 
mehdi_mAuthor Commented:
I guess so that it's imposible. by the way my client-server program is a user accounting program that manage a network for controlling the usage of computers by different users.

So I think, when the user account is finished, there will be no way unless restarting the windows. In any way thank you 2 for your helps and attentions.

mehdi_m

0
 
mehdi_mAuthor Commented:
;)  I found the solution myself, it's simple.

just put BlockInput(True) statement in a timer untill the server tell that to stop the timer and BlockInput(False).

 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.