-
Exiting Windows
Hi there,
I wnat to know if i can close the Windows OS itself from my Program. I mean to say that if my program is closed/exited. the system should shutdown automatically.
I've tried using ExitWindowsEx as below;
Dim i As Boolean
i = ExitWindowsEx(EWX_SHUTDOWN + EWX_FORCE, 0)
but it only logsoff the cureent user. it is not shutting down the system. Any help is welkome.
Thnx in adv.
-
Hi there,
with ExitWindowsEx() api
try different combinations of parameters.
Yes, I did get ur result with 1,1 in the parenthesis,
try out exitwindowsex(1,10). It should shut down windows.
Reply if u have got the solution.
Cheers,
Ven.
-
Code:
'In general section
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 End
'reboot the computer
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
End Sub
-
Thanx
hi VlatKo & venkrishna,
Thnx for ur reply i've tried both of ur codes. they are working fine and r very useful to me.
Thnx once again.
:D :D :D :D :D :D :D ;) ;)