Fungsi-fungsi untuk Lock, Hibernate, Logoff, Shutdown Windows pada VB.NET

Harus import:
using System.Runtime.InteropServices;

Lock Computer:

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

Kemudian panggil fungsinya:
LockWorkStation();

Logoff:

[DllImport(“user32.dll”)]
public static extern int ExitWindowsEx(int uFlags, int dwReason);

Panggil fungsinya:
Logoff biasa:
ExitWindowsEx(0, 0);
Logoff force:
ExitWindowsEx(4, 0);

Reboot:
ExitWindowsEx(2, 0);

Shutdown:
ExitWindowsEx(1, 0);

Hibernate:
Application.SetSuspendState(PowerState.Hibernate, true, true);
Standby:
Application.SetSuspendState(PowerState.Suspend true, true);

Bagus kan??

3 thoughts on “Fungsi-fungsi untuk Lock, Hibernate, Logoff, Shutdown Windows pada VB.NET

  1. Jadi mengingatkan ak sama programming yang dulu, VB n C#.. eheheheh!! sekarang dah full of Java pak..! :D

    Maju terus deh trainingnya..!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s