Lock, Logoff, Reboot, Shutdown, Hibernate, Standby in .Net This
article is about locking, logging off , rebooting, shutting
down, hibernating and putting the system on stand by mode in
.Net. Here we are going to use both unmanaged code and .Net
framework for these functions. Let us start by creating a
windows application. To our newly created form, add seven
buttons entitled btnLockComp, btnLogOff, btnReboot, btnShutdown,
btnForceLogOff, btnHibernate, btnStandby. Let us start with
locking the workstation, which is supposed to lock the current
user session. We will call a windows API for doing this. For
calling an un-managed piece of code, we need to add the
System.Runtime.InteropServices namespace to the using directive.
Now we are ready to import the windows API library and define
the function that we intend to use. The function to lock the
workstation resides in the user32.dll library. And the function
for locking the desktop is LockWorkStation. The following
statements should be added to the class to impor