Lock Workstation through Code , Locking Workstation

10 Sep

Reposting from prev blog

Idle mind is Devils Workshop!!

Today didnt have much tasks to work on as had already finished the task expected to go on till today evening ,hence had loads of free time to try out stuff
Found this link Lockworkstation Function and thouht of implementing it in .NET since I hated the idea of

CTRL + ALT + DEL and ENTER / Win + L to lock my workstation.

Anyways here it is the code

You will need to include the Namespace
using System.Runtime.InteropServices;

Copy the following in the Code behind


public static extern void LockWorkStation();

And in the form load event give a call to the LockWorkStation Method we declared above.

private void LockStation_Load(object sender, System.EventArgs e)


Thats it you are done !! Copy the Assembly from the bin folder onto your desktop and click on it whenever you want to Lock your workstation!!


Leave a comment

Posted by on September 10, 2008 in .NET


Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: