CISA FotoGallery

Statistiche

Tot. visite contenuti : 928201
Home Articoli tecnici Moduli Accendere, spegnere e loggare il PC

Accendere, spegnere e loggare il PC

Ecco il codice per spegnere o riavviare il pc o fare il logout

Option Compare Database
Option Explicit

Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1
Public Const EWX_REBOOT = 2
Public Const EWX_FORCE = 4
Public Const EWX_POWEROFF = 8

Declare Function smsExitWindows Lib "user32" Alias "ExitWindows" (ByVal dwReserved As Long, ByVal uReturnCode As Long)
As Long

Declare Function smsExitWindowsEx Lib "user32" _
Alias "ExitWindowsEx" (ByVal uFlags As Long, _
ByVal dwReserved As Long) As Long

Public Sub ByeWindowsTests(plngExitMode)
Dim varDummy
''varDummy = smsExitWindowsEx(EWX_SHUTDOWN, 0&)
'''varDummy = smsExitWindowsEx(EWX_REBOOT, 0&)
'''varDummy = smsExitWindowsEx(EWX_LOGOFF, 0&)
'''varDummy = smsExitWindowsEx(EWX_FORCE + EWX_POWEROFF + EWX_SHUTDOWN, 0&)
varDummy = smsExitWindowsEx(plngExitMode, 0&)
End Sub

Public Function smsReboot()
'Call smsExitWindowsEx(EWX_SHUTDOWN Or EWX_FORCE, 0&)
Call smsExitWindowsEx(EWX_REBOOT, 0&)
End Function