Thursday, October 14, 2010

C# code for Lock windows

This simple code segment explain you, How to lock windows using C# code (same as pressing Windows logo key and the letter L)




This is nothing but calling of “C:\WINDOWS\system32\rundll32.exe user32.dll, LockWorkStation” command from C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;


namespace Sajid.LockComputer

{

class Program
{
static void Main(string[] args)
{
Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation") ;
}
}
}

No comments: