-2

Hello, is there a way to create a .exe or button in C# to do the same as WIN+L? Thanks

Don Vito
  • 103
  • 4
  • possible duplicate of: http://stackoverflow.com/questions/1263047/lock-windows-workstation-programmatically-in-c-sharp and http://stackoverflow.com/questions/13745788/how-do-i-lock-a-windows-workstation-programmatically – Koryu Jun 17 '15 at 10:36

1 Answers1

1

You can use the following:

//using System.Runtime.InteropServices;

[DllImport("user32", SetLastError = true)]
static extern bool LockWorkStation();

And then just call within your button_Click:

LockWorkStation();
cramopy
  • 3,459
  • 6
  • 28
  • 42