Search Forum
(57415 Postings)
Search Site/Articles

Archived Articles
712 Articles

C# Books
C# Consultants
What Is C#?
Download Compiler
Code Archive
Archived Articles
Advertise
Contribute
C# Jobs
Beginners Tutorial
C# Contractors
C# Consulting
Links
C# Manual
Contact Us
Legal

GoDiagram for .NET from Northwoods Software www.nwoods.com


              
Printable Version

Lock Your Computer
By Adam Karim

So, in my quest for the perfect way to lock my Windows 2000 Pro, Server, or Advanced Server since none have the "Window Key" + "L" that was introduced with XP. I've used such things as shortcuts and Windows Scripting host in order to quickly lock it but I wanted something easily transferable. Well, here ya go, easy code to lock your comp:

namespace LockUp
{

 using System;
 using System.Runtime.InteropServices;

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

 class Lock
 {

  static void Main(String[] args)
  {
   LockWorkStation();
  }
 }
}
Simple stuff but very useful;)