How to shut down the system using vb.
if we select the time to shut down it should close all the application and then it should shut down.
Printable View
How to shut down the system using vb.
if we select the time to shut down it should close all the application and then it should shut down.
Moved from FAQ section
I knew that Classic VB should be first, cause new comers would get confused. Anyways this is how:
VB Code:
Const EWX_LOGOFF = 0 Const EWX_SHUTDOWN = 1 Const EWX_REBOOT = 2 Const EWX_FORCE = 4 Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Private Sub Form_Load() msg = MsgBox("This program is going to reboot your computer. Press OK to continue or Cancel to stop.", vbCritical + vbOKCancel + 256, App.Title) If msg = vbCancel Then Unload Me ExitWindowsEx EWX_FORCE Or EWX_SHUTDOWN, 0 End Sub