Membuat program ShutDown


Bingung neh, gimana ya caranya buat program yang udah selesai diinstal trus restart sendiri?

Berikut ini adalah contoh kode untuk membuat perintah agar program bisa shutdown, restart, logoff.

‘ketik pada module

Option Explicit
Declare Function CdRoOmX Lib “winmm.dll” Alias “mciSendStringA” (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function ExitWindowsEx Lib “user32” (ByVal uflags As Long, ByVal dwReserved As Long) As Long
Public Const EXIT_LOGOFF = 0
Public Const EXIT_SHUTDOWN = 1
Public Const EXIT_REBOOT = 2

Public Sub MyPowerX(ByVal uflags As Long)
Call ExitWindowsEx(uflags, 0)
End Sub

‘ketik pada form
‘buat 3 commondbutton pada form

Private sub CmdLogOffMe_click()
myPowerX 0 ‘LogOff
end sub

private sub CmdShutDownMe_click()
myPowerX 1 ‘Shutdown
end sub

private sub CmdRebootMe_click()
myPowerX 2 ‘Reboot
end sub

‘end of code

About

Flexter member

Posted in VB 6.0

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

%d bloggers like this: