Screen Lock Button, Unlock by using password in VB.net

Unanswered Screen Lock Button, Unlock by using password in VB.net

  • 2012年3月12日 14:00
     
     

    Hi everyone, I'm a newbie in vb.net and in my program using vb.net and ms access, I need a button in my program that can lock the screen, For example when button is pressed the screen is lock wid a background picture with one textbox or simply using windows forms, and it could only be unlock using the account password of the cashier that is logged in to the program.

    What I mean by screen lock is that... it cant do anything to the desktop or to the computer unless the password of the cashier is inputed correctly.

    Thank You and Godbless, Happy Programming Everyone..^^

全部回复

  • 2012年3月12日 14:05
     
     
    Why not rely on the Windows Lock screen?

    Jose R. MCP

  • 2012年3月13日 15:08
     
     
    Yeah good idea, but actually our teacher just suggested if we could do it in vb.net, then will add it on our project.
  • 2012年3月13日 15:13
     
     
    You can force the workstation to lock by P/Invoking the user32.dll function LockWorkStation().  No other solution (short of creating a new desktop) will fulfill the purpose because users can, for example, terminate the process that is showing the locked screen using Task Manager.

    Jose R. MCP

  • 2012年3月13日 15:20
     
     

    Oh.. Honestly I dont get it... Im a newbie. nyway my priority problem is here:

    http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/8193d227-8af2-4451-bbe0-09aa7e2fb26e

    If your not busy could you help me about that link. please.

    Our teacher just suggested bout locking the desktop, so if we get it or dont, it wil be just ok. :), Thanks for the help.

  • 2012年3月14日 8:53
    版主
     
      包含代码

    Hi GodspeedSupreme,

    You may show(use ShowDialog()) the lock screen (which contains textboxes that for user to enter UserName and Password) as a windows form in the button's click event. And this lock screen form will be show with ShowDialog. Something similar to: 

            private void button1_Click(object sender, EventArgs e)
            {
                LockScreenForm.ShowDialog();
            }

    And the LockScreenForm can be looks like

    and the code on the LogON button will check if the entered UserName and Password is correct, if correct, then unlock the screen, coding like this: http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/baa85c20-7f6a-4c92-9917-24b6fa39ca67/ 

    Sincerely,


    Helen Zhou [MSFT]
    MSDN Community Support | Feedback to us

  • 2012年3月14日 8:54
    版主
     
     
    Or you may have a look at this thread with the same topic : making a lock screen in visual c# and How can I lock the screen using C#? Hope them help too.

    Helen Zhou [MSFT]
    MSDN Community Support | Feedback to us

  • 2012年3月15日 3:08
     
     
    Thanks for the help but what I mean for the lock screen form is that, when lockscreen button is press, Other user's cant do anything to the computer unless theyve input the correct password. just like logging in to windows, if wrong password and id, yu cant do somthing to the desktop, so I have to make a lockscreen that the other users cant use tab, or minimized the form and neither can he access the windows task manager. unless inputed the right password.
  • 2012年3月15日 8:12
    版主
     
     
    Yes, I know that, I missed the part that set the LockScreenForm's ControlBox property to false, so that one can not ignore the form by click the CLOSE control button, thus once the LockScreenForm is going to show as a modal form (using ShowDialog) which means code following it is not executed until after the dialog box is closed. Once the username and password is correctly inputted.

    If this is not the way you like, please try the following links in my last reply.

    Helen Zhou [MSFT]
    MSDN Community Support | Feedback to us

  • 2012年3月15日 13:56
     
     
    What the OP describes is the EXACCT FUNCIONALITY provided by Windows.  Why on Earth would you want to re-code or even attempt to re-code something that is ONE function call away?  And it is not like you will be coding it as good.  Your version is bound to be less secure.  Use LockWorkStation() from user32.dll.  Newbie in P/Invoke?  Well, time to shake it off an learn it.

    Jose R. MCP