Here is the sample windows application which does this task by using two APIs from user32.dll.
namespace Lock_Display
{
static class Program
{
private const int WmSyscommand = 0x0112;
private const int ScMonitorpower = 0xF170;
private const int HwndBroadcast = 0xFFFF;
private const int ShutOffDisplay = 2;
[DllImport("user32.dll")]
private static extern void LockWorkStation();
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(IntPtr hWnd, uint msg,
IntPtr wParam, IntPtr lParam);
private static void TurnOffDisplay()
{
PostMessage((IntPtr)HwndBroadcast, (uint)WmSyscommand,
(IntPtr)ScMonitorpower, (IntPtr)ShutOffDisplay);
}
[STAThread]
static void Main()
{
LockWorkStation();
TurnOffDisplay();
}
}
}