PDA

Click to See Complete Forum and Search --> : Exiting Windows


cutamacious
May 22nd, 2001, 03:47 AM
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.

Venkrishna
May 22nd, 2001, 04:00 AM
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.

Vlatko
May 22nd, 2001, 05:38 AM
'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

cutamacious
May 23rd, 2001, 12:41 AM
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 ;) ;)