You need to override 'wndproc'
Declaration:
' Exit Windows message
Private Shared WM_QUERYENDSESSION As Integer = &H11
#Region "Window Proc (SUB)"
<System.Security.Permissions.PermissionSetAttribut e(System.Security.Permissions.SecurityAction.Deman d, Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
' Listen for operating system messages
If m.Msg = WM_QUERYENDSESSION Then
' Close the application
Application.Exit()
End If
' Handle the message
MyBase.WndProc(m)
End Sub
I hope this helps
"Ken Tucker [MVP]" wrote:
Hi,
The forms closing event allows you to cancel the form from closing.
If you cancel a form from closing it would prevent windows from shutting
down or logging off.
Ken
-------------------
"Jm" <ja*****@ihug.com.au> wrote in message
news:ct**********@lust.ihug.co.nz...
Hi All
I have a simple vb.net app that once run for some reason does not allow me
to log off or shutdown the pc ? When i try to do so it will close my app and
then will only shutdown or logoff if i attempt to do so once again ? Does
anybody have any does why this would be so ?