2

I want to lock the accessing of current operating user, as if the user

clicked on Start → pointed to shutdown → click on LOCK

How to do that in C#?

Ken Kin
  • 4,351
  • 3
  • 37
  • 73
sharp12345
  • 4,190
  • 3
  • 21
  • 37
  • You can make an application that runs the following command line. No Dll imports involved here. http://www.idsecuritysuite.com/blog/how-to-lock-your-computer-using-command-line – Adrian Marinica Feb 08 '13 at 14:47
  • Are you trying authorize the user? Maybe as an admin? http://stackoverflow.com/questions/3583501/c-net-acquire-administrator-rights – MrFox Feb 08 '13 at 14:49

2 Answers2

4

http://jessn.blogspot.com/2009/05/lock-my-computer-programatically-in-c.html This article says it best:

A much better design that isn't hard coded to your windows system paths, etc:

using System.Runtime.InteropServices;

[DllImport("user32.dll")] public static extern void LockWorkStation();

Then just call LockWorkStation();

Eli Gassert
  • 9,556
  • 3
  • 27
  • 37
0
 System.Diagnostics.Process.Start("shutdown.exe -l");





      it will LOG OFF your computer and now if the account has secure with some password then windows will ask for password otherwise not.
Hiren
  • 41
  • 1