Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Lock Monitor, Keyboad and Mouse - How???

Lock Monitor, Keyboad and Mouse - How???

Scheduled Pinned Locked Moved Visual Basic
csharpjsonquestion
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tommy_tanaka
    wrote on last edited by
    #1

    Hi there - i have to implement a remote control for clients. this control should be able to lock the client-workstation - in simple words: monitor black, keyboard and mouse locked. I develope the program in VB.net and on the clients a service will run. and within this service, i want to call a function that does the things for me i just talked about. but i have no idea what function (i think it is a win API function in GDI32) i have to use to do the locking. or has anyone a better idea? i am open for all suggestions. thanks a lot for all replies. happy coding. tom

    D 1 Reply Last reply
    0
    • T tommy_tanaka

      Hi there - i have to implement a remote control for clients. this control should be able to lock the client-workstation - in simple words: monitor black, keyboard and mouse locked. I develope the program in VB.net and on the clients a service will run. and within this service, i want to call a function that does the things for me i just talked about. but i have no idea what function (i think it is a win API function in GDI32) i have to use to do the locking. or has anyone a better idea? i am open for all suggestions. thanks a lot for all replies. happy coding. tom

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There is no one function that will lock the keyboard and mouse. You have to write code to hook the keyboard and mouse and eat any messages that are sent your way from the keyboard and mouse drivers. Unfortunately, you can't keep the user from using Ctrl-Alt-Del. This key combination cannot be trapped. There is a great article on CodeProject by Michael Kennedy called "Global System Hooks in .NET" [^] that demonstrats this technique. Your service must also be set to "Allow interaction with Desktop" so that you can put up a form that covers the entire desktop area and tag that form as TopMost. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      T 1 Reply Last reply
      0
      • D Dave Kreskowiak

        There is no one function that will lock the keyboard and mouse. You have to write code to hook the keyboard and mouse and eat any messages that are sent your way from the keyboard and mouse drivers. Unfortunately, you can't keep the user from using Ctrl-Alt-Del. This key combination cannot be trapped. There is a great article on CodeProject by Michael Kennedy called "Global System Hooks in .NET" [^] that demonstrats this technique. Your service must also be set to "Allow interaction with Desktop" so that you can put up a form that covers the entire desktop area and tag that form as TopMost. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        T Offline
        T Offline
        tommy_tanaka
        wrote on last edited by
        #3

        thank you very much for your hints. the article seems to be what i was lookin' for ... do you have an example how this thing with "allow interaction with desktop" works? anyway- thanks for your help. tom

        D 1 Reply Last reply
        0
        • T tommy_tanaka

          thank you very much for your hints. the article seems to be what i was lookin' for ... do you have an example how this thing with "allow interaction with desktop" works? anyway- thanks for your help. tom

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Easy. When you instlal your service on the client, go into the Services control panel and find your service. Double-Click on it to bring up its properties and click on the LogOn tab. Make sure it is using the Local System Account and click on the Allow Service to interact with desktop checkbox. Click OK and your done. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          T 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Easy. When you instlal your service on the client, go into the Services control panel and find your service. Double-Click on it to bring up its properties and click on the LogOn tab. Make sure it is using the Local System Account and click on the Allow Service to interact with desktop checkbox. Click OK and your done. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            T Offline
            T Offline
            tommy_tanaka
            wrote on last edited by
            #5

            The hook article is very interesting. but at the moment i'm thinkin' if i could not find an easier solution. if i put up a form that covers the entire desktop and make it topMost - all i have to do then, is to avoid the user from closing the window by pressing the "x" in the upper right corner or pressing alt+F4. right? maybe i can catch this in a way easier than to hook the keyboard. but then - the user still can press strg+alt+del and kill the form in the taskmanager, can't he?

            D 1 Reply Last reply
            0
            • T tommy_tanaka

              The hook article is very interesting. but at the moment i'm thinkin' if i could not find an easier solution. if i put up a form that covers the entire desktop and make it topMost - all i have to do then, is to avoid the user from closing the window by pressing the "x" in the upper right corner or pressing alt+F4. right? maybe i can catch this in a way easier than to hook the keyboard. but then - the user still can press strg+alt+del and kill the form in the taskmanager, can't he?

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              tommy_tanaka wrote: the user still can press strg+alt+del and kill the form in the taskmanager, can't he? Yep. Locking a machine is not as easy as it would sound. There's really no other way of doing this. There is no function you can call to turn off the keyboard and mouse, simply because there is no practical use for it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              T 1 Reply Last reply
              0
              • D Dave Kreskowiak

                tommy_tanaka wrote: the user still can press strg+alt+del and kill the form in the taskmanager, can't he? Yep. Locking a machine is not as easy as it would sound. There's really no other way of doing this. There is no function you can call to turn off the keyboard and mouse, simply because there is no practical use for it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                T Offline
                T Offline
                tommy_tanaka
                wrote on last edited by
                #7

                shit ... well - what do you think of this idea: the running service remembers if an form has to be popped up or not. if so, it always checks, if the form is still alive, otherwise it pops it up again. or better, in the destructor of the form, the object itself checks, if it should popup again or not. to kill a running service will be much more difficult for an usual user, than just to call strg+alt+delete to kill the form. what's your thinking about this?

                D 1 Reply Last reply
                0
                • T tommy_tanaka

                  shit ... well - what do you think of this idea: the running service remembers if an form has to be popped up or not. if so, it always checks, if the form is still alive, otherwise it pops it up again. or better, in the destructor of the form, the object itself checks, if it should popup again or not. to kill a running service will be much more difficult for an usual user, than just to call strg+alt+delete to kill the form. what's your thinking about this?

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  I've got a question... What's the point behind all of this? Why lock the workstation anyway? tommy_tanaka wrote: to kill a running service will be much more difficult for an usual user, than just to call strg+alt+delete to kill the form. You can't kill just a form. A form is part of an application, or service. And don't put it past any user that they can't figure out what to kill off in the process list, which your service will be apart of... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                  J 1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    I've got a question... What's the point behind all of this? Why lock the workstation anyway? tommy_tanaka wrote: to kill a running service will be much more difficult for an usual user, than just to call strg+alt+delete to kill the form. You can't kill just a form. A form is part of an application, or service. And don't put it past any user that they can't figure out what to kill off in the process list, which your service will be apart of... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                    J Offline
                    J Offline
                    James Gohl
                    wrote on last edited by
                    #9

                    I know an excellent method of locking the computer, although I'm not sure of any API's that might help, if you could purposely lock the machine or BSOD it (Blue Screen Of Death) - would that be helpful? lol. Try this: On Windows 98 goto Start, Run and type con/con and you get a nice BSOD! hehe :D Or... alternatively you could try my more serious solution: - Set the border of the form to 0 so it has no title bar etc... - Make the form top-most using the SetWindowPos API - Disable keyboard and mouse input using the BlockInput API (with params TRUE or 1) call this in a 1 milli second timer! Now the only key combo that works is C.A.D (or S.A.D as you lot call it) I know this is a pain in WinXP but, there is a way around that with a simple registry hack. Change following in the registry (if it doesn't exist - create the keys and the value) HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\ Create a REG_DWORD value under this key called DisableTaskmgr and set it to 1 Because there is no simple way to do this I have come up with a bit of a patchy method but it works. Watch out for that windows key ;) Oh yeah one last thing make the background color of the form blue so it looks like a BSOD :D

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups