Program Shutdown


Program ini di buat dengan bahasa pemrograman visual basic 6.0 . gunanya selain untuk men-shutdown, juga bisa di gunakan untuk restart, logoff. Komponen yang harus di persiapkan di VB adalah :

·Sebuah Form

·4 Buah Command Bottom

CONTOH PROGRAM :

http://www.4shared.com/file/137628102/e571eb7/windor.html

Adapun listingnya adalah sebagai berikut :

Option Explicit

Private Const EWX_FORCE As Long = 4

Private Type LUID

UsedPart As Long

IgnoredForNowHigh32BitPart As Long

End Type

Private Type TOKEN_PRIVILEGES

PrivilegeCount As Long

TheLuid As LUID

Attributes As Long

End Type

Public Enum ExitWindows

logoff = 0

SHUTDOWN = 1

REBOOT = 2

POWEROFF = 8

End Enum

#If False Then

Private logoff, SHUTDOWN, REBOOT, POWEROFF

#End If

Private Declare Function ExitWindowsEx Lib “user32” (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Private Declare Function GetCurrentProcess Lib “kernel32” () As Long

Private Declare Function OpenProcessToken Lib “advapi32” (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long

Private Declare Function LookupPrivilegeValue Lib “advapi32” Alias “LookupPrivilegeValueA” (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long

Private Declare Function AdjustTokenPrivileges Lib “advapi32” (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long

Private Sub AdjustToken()

Dim hdlProcessHandle As Long

Dim tmp As String

Dim hdlTokenHandle As Long

Dim tmpLuid As LUID

Dim tkp As TOKEN_PRIVILEGES

Dim tkpNewButIgnored As TOKEN_PRIVILEGES

Dim lBufferNeeded As Long

hdlProcessHandle = GetCurrentProcess()

OpenProcessToken hdlProcessHandle, (&H20 Or &H8), hdlTokenHandle

LookupPrivilegeValue “”, “SeShutdownPrivilege”, tmpLuid

With tkp

.PrivilegeCount = 1

.TheLuid = tmpLuid

.Attributes = &H2

End With

AdjustTokenPrivileges hdlTokenHandle, False, tkp, Len(tkpNewButIgnored), tkpNewButIgnored, lBufferNeeded

End Sub

Public Sub KeluarWindows(ByVal aOption As ExitWindows)

AdjustToken

Select Case aOption

Case ExitWindows.logoff

ExitWindowsEx (ExitWindows.logoff Or EWX_FORCE), &HFFFF

Case ExitWindows.REBOOT

ExitWindowsEx (ExitWindows.SHUTDOWN Or EWX_FORCE Or ExitWindows.REBOOT), &HFFFF

Case ExitWindows.SHUTDOWN

ExitWindowsEx (ExitWindows.SHUTDOWN Or EWX_FORCE), &HFFFF

Case ExitWindows.POWEROFF

ExitWindowsEx (ExitWindows.POWEROFF Or EWX_FORCE), &HFFFF

End Select

End Sub

Private Sub Command1_Click()

KeluarWindows logoff

End Sub

Private Sub Command2_Click()

KeluarWindows POWEROFF

End Sub

Private Sub Command3_Click()

KeluarWindows REBOOT

End Sub

Private Sub Command4_Click()

KeluarWindows SHUTDOWN

End Sub

Untuk menjalankannya anda tinggal klik salah satu tombol. Dan perintahpun akan di jalankan tanpa konfirmasi. Demikian program yang saya buat semoga bermanfaat untuk anda…aamiin

 

Depok, 9-8-08-sbt

noname

Advertisements

5 Responses

  1. senang kenal dengan Anda. saya juga membuat program sejenis dengan menggunakan timer.

    Like

  2. Assalamualaikum salam kenal 🙂
    ngomong2 sekarang masih kuliah di gundar ga ni ? 🙂

    Like

    • wa’alaikum salam. alhamd saya masih kuliah di gunadarma. sedang melanjutkan pendidikan pascasarjana.

      Like

  3. Alhamdulillah semoga kuliahnya lancar y kang.. 🙂
    sy juga anak gundar dari fakultas teknik sipil

    Like

    • aamiin
      salam kenal

      Like

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: