PC Review


Reply
Thread Tools Rate Thread

Canceling and continuing shutdown/reboot/logoff

 
 
Allan Bredahl
Guest
Posts: n/a
 
      5th Feb 2004

Hi All


I am trying to construct an application that is able to cancel a machine
shutdown, reboot or logoff. And after performing some stuff to perform the
original shutdown order : Shutdown/reboot/logoff.

I have tried this :

AddHandler Microsoft.Win32.SystemEvents.SessionEnding, AddressOf
ShutDown.OnShuttingdown

Public Shared Sub OnShuttingdown(ByVal sender As Object, ByVal e As
Microsoft.Win32.SessionEndingEventArgs)
e.Cancel = True
End Sub

But this doesn't seem to work since the canceling of the system shutdown
does not cancel the application shutdown and therefore it gives no meaning
THe only way I can prevent the app closing down is by showing a messagebox i
my OnShuttingDown handler. But if I do not close the messagebox within an
couple of seconds the system tries to close this and then continues the
shutdown regardless that the cancel = true have been set.



Then I tried this which work better, but my problem here is, that I do not
know if I'm handling a shutdown, reboot or logoff:


Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
ShutDown.systemShutdown = True
End If

MyBase.WndProc(m)
End Sub

Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If (ShutDown.systemShutdown) Then
ShutDown.systemShutdown = False
e.Cancel = True
Else
e.Cancel = False
Application.Exit()
End If
End Sub


Does anyone know how to do this, so I'm able to stop and continue any type
of 'shutdown'


Thanks in advance

Allan Bredahl



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logoff, reboot or shutdown Just D. Windows XP General 6 17th Feb 2009 03:29 PM
SessionEnding event and other application canceling logoff =?Utf-8?B?RGFuIFM=?= Microsoft Dot NET Framework Forms 0 31st Jul 2004 12:19 AM
(Work-around) Cannot normally logoff, reboot, or shutdown remotely with ATI Radeon driver Robb Topolski Windows XP Work Remotely 0 27th Jun 2004 04:24 PM
The only way for me to logoff,shutdown, reboot etc... Jeanie Windows XP Accessibility 0 29th Aug 2003 12:28 PM
Re: Reboot instead of logoff Mark V Microsoft Windows 2000 0 18th Aug 2003 01:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:47 AM.