Quick Shortcut to Lock Workstation

Quick Shortcut to Lock Workstation

We normally use QuickLaunch bar in System Taskbar for almost any of our tasks. When we want go away from our system, we normally lock the workstation. Just a curious tip. A simple two three lines of code in C# can place a nice application whose shortcut can be placed in QuickLaunch bar to Lock the Workstation.

Console Version

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace QuickLock
{

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

             static void Main(String[] args)
            {
                     try
                          {
                                 LockWorkStation();
                          }
                          catch (Exception ee)
                         {
                               MessageBox.Show(ee.Message);
                          }
              }
       }
}

Alternatively,if you put the code in Windows Form and you can customize the App.ICO to some friendly ICO file which will showup in QuickLaunch bar instead of the old rectangle which shows up for an EXE.


/* Migrated from Daffodilnet Express — posted on October 15, 2004 */

One thought on “Quick Shortcut to Lock Workstation”

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>