4
Aplikasi Shutdown-Restart-Logoff Komputer Otomatis dengan VB 6
Aplikasi Timer PC ini adalah aplikasi untuk Restart, Shutdown dan Log
Off computer / laptop anda secara otomatis dan berjalan di windows. Cara
kerjanya adalah dengan menentukan waktu kapan computer akan Restart/LogOff atau
shutdown maka saat waktu computer sama dengan waktu setingan maka computer akan
menjalankan peritah yang sudah kita pilih.
Langkah 1 : Jalankan Aplikasi Visual Studio 6.0 kamu
Langkah 2 : Desain Form1 Seperti gambar dibawah ini :
Langkah 3 : Atur control properties form1 sesuai table dibawah ini
No
|
Kontrol
|
Properties
|
1
|
Label
|
Name : Label1
Caption : Timoresse Timer PC
|
2
|
Label
|
Name : Label2
Caption: 00:00:00
|
3
|
Label
|
Name : Label3
Caption: Label3
|
4
|
ComboBox
|
Name : Combo1
|
5
|
TextBox
|
Name : Text1
Text : 00:00:00
|
6
|
CommandButton
|
Name : cmd_set
Caption : Set
|
7
|
Timer
|
Name : Timer1
Inerval : 1000
|
8
|
Timer
|
Name : TimerLogOff
Inerval : 1000
|
9
|
Timer
|
Name : TimerRestart
Inerval : 1000
|
10
|
Timer
|
Name : TimerShutdown
Inerval : 1000
|
11
|
Timer
|
Name : TimerBlink
Inerval : 1000
|
Langkah 4 : Masukan script code berikut ke halaman program form1
tersebut
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
Combo1.AddItem "-------"
Combo1.AddItem "Log Off"
Combo1.AddItem "Restart"
Combo1.AddItem "Shutdown"
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Label2 = Time
End Sub
Private Sub Combo1_Click()
'////Log Off////
If Combo1 = "Log Off" Then
Label3.Caption = "Log Off : " + Text1
TimerLogOff.Enabled = True
TimerRestart.Enabled = False
TimerShutdown.Enabled = False
'////restart pc////
ElseIf Combo1 = "Restart" Then
Label3.Caption = "Restart : " + Text1
TimerLogOff.Enabled = False
TimerRestart.Enabled = True
TimerShutdown.Enabled = False
End If
'/////shutdown pc/////
If Combo1 = "Shutdown" Then
Label3.Caption = "Shutdown : " + Text1
TimerLogOff.Enabled = False
TimerRestart.Enabled = False
TimerShutdown.Enabled = True
End If
End Sub
Private Sub TimerBlink_Timer()
If Label3.Visible = True Then
Label3.Visible = False
Else
Label3.Visible = True
End If
End Sub
Private Sub TimerLogOff_Timer()
If Text1 = Time Then
'////log off///
Shell "shutdown -l -f -t 0"
End If
End Sub
Private Sub TimerRestart_Timer()
If Text1 = Time Then
'////restart///
Shell "shutdown -r -f -t 0"
End If
End Sub
Private Sub TimerShutdown_Timer()
If Text1 = Time Then
'////restart///
Shell "shutdown -s -f -t 0"
End If
End Sub
Private Sub cmd_set_Click()
If Text1 >= Label2 Then
cmd_set.Enabled = False
Text1.Enabled = False
TimerBlink.Enabled = True
ElseIf Text1 < Label2 Then
MsgBox "Setingan waktu telah expired!", vbOKOnly, "timoresse.blogspot.com"
FormTimer.Refresh
Text1.SetFocus
Text1 = "00:00:00"
End If
End Sub
Langkah 5 : Tekan F5 untuk menjalankan
dan testing program. Apabila program berjalan dengan benar maka akan
tampil aplikasi seperti gambar dibawah ini.
Demikian Tutorial Singkat membuat Timer PC dengan VB 6
Semoga bermanfaat,
Terima Kasih,
Download Source Code dan Tutorial versi PDF klik disini



