Hi All
I have an app that when running if a user selects logoff or shutdown from
the start menu, it will close itself but not logoff windows or shutdown.
From what i have found so far its most likely something ive declared in my
program that is preventing the logoff, i have tried closing and disposing
forms and sql connections, is there anything else i should be looking for ?
Or some way to step through it to find what is causing this
Many thanks 8 3438
' You need to look at consuming QUERYENDSESSION in WndProc to do what you
want
' Declaration:
' ------------
Private Shared WM_QUERYENDSESSION As Integer = &H11
' Paste in the following sub:
' --------------------------
#Region "Window Proc (SUB)"
<System.Security.Permissions.PermissionSetAttribut e(System.Security.Permissi
ons.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
' Listen for operating system messages
If m.Msg = WM_QUERYENDSESSION Then
' Handle the closing of your program here. If you have the form closing
to the System Tray then you need to handle the Form_Closing event (see
below)
End If
' Handle the message
MyBase.WndProc(m)
End Sub
#End Region
' When I minimise to System Tray, I set Cancel = True, but when Windows is
closing down, I make sure that Cancel = False allowing the closing of the
application. This can be down with a simple boolean value:
Dim blnIsWindowsClosing As Boolean = False
' In Form Closing:
' -----------------
If blnIsWindowsClosing = True Then
e.Canel = True
else
e.Cancel = False
End If
' So, now in the QUERYENDSESSION (WndProc), set :
' ----------------------------------------------------------
blnIsWindowsClosing = True
' Obviously, if you do not want to minimise to System Tray then just use the
QUERYENDSESSION constant & the WndProc sub
' Its as easy as that. It works for Logoff, Restart & Shutdown
I hope this helps
Crouchie1998
BA (HONS) MCP MCSE
It sounds like a feature that someone else could be loocking for .......
:-)
i would try to isolate this bug if i were you ,,,,, you might get good money
for it
:-)
"Jm" <ja*****@ihug.com.au> wrote in message
news:d4**********@lust.ihug.co.nz... Hi All
I have an app that when running if a user selects logoff or shutdown from the start menu, it will close itself but not logoff windows or shutdown. From what i have found so far its most likely something ive declared in my program that is preventing the logoff, i have tried closing and disposing forms and sql connections, is there anything else i should be looking for
? Or some way to step through it to find what is causing this
Many thanks
"Jm" <ja*****@ihug.com.au> schrieb: I have an app that when running if a user selects logoff or shutdown from the start menu, it will close itself but not logoff windows or shutdown. From what i have found so far its most likely something ive declared in my program that is preventing the logoff, i have tried closing and disposing forms and sql connections, is there anything else i should be looking for ?
You may want to watch for a shutdown and then terminate your application
yourself instead of waiting for Windows to do so.
<URL:http://dotnet.mvps.org/dotnet/samples/windowsandforms/CloseWindow.zip>
Take a look at 'SystemEvents.SessionEnding' too.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
JM,
What OS is the user using. It gives me slightly the idea that you are
talking about a user who has a W98/Me while the program is in a loop.
Cor
If you looked at my original code then that will do exactly what you need.
Crouchie1998
BA (HONS) MCP MCSE
Sorry to go off topic, but...
LOL! Every cloud has a silver lining!
Actually, the idea of having a program that inhibits logoff and shutdown
might be interesting. If you don't want someone to accidentally shutdown
your machine or log you off, you just lock your screen, but if it's a shared
machine that many users have access to....
Let's say you have a computer that is shared by several people in a
department. One user is running a critical app, so they don't want the
machine shutdown or their session logged off. So they run this app. The
other users could still "Switch User" to their accounts. The app would have
to run with admin privlidges, because it would have to inhibit shutdown from
all accounts, plus logoff from whichever account initiated the app.
Interesting.
Of course, no matter what the app is capable of, it couldn't prevent someone
from pulling the plug!
Lee
"M. Posseth" <mi*****@nohausystems.nl> wrote in message
news:d4**********@reader08.wxs.nl... It sounds like a feature that someone else could be loocking for .......
:-)
i would try to isolate this bug if i were you ,,,,, you might get good money for it
:-)
"Jm" <ja*****@ihug.com.au> wrote in message news:d4**********@lust.ihug.co.nz... Hi All
I have an app that when running if a user selects logoff or shutdown from the start menu, it will close itself but not logoff windows or shutdown. From what i have found so far its most likely something ive declared in my program that is preventing the logoff, i have tried closing and disposing forms and sql connections, is there anything else i should be looking for ? Or some way to step through it to find what is causing this
Many thanks
Hi Cor
Nope, noticed it on Win2k/XP machines
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uH**************@TK2MSFTNGP14.phx.gbl... JM,
What OS is the user using. It gives me slightly the idea that you are talking about a user who has a W98/Me while the program is in a loop.
Cor
Hi Crouchie
Thanks for the reply, worked straight away, manuy thanks once again
"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:u0*************@TK2MSFTNGP12.phx.gbl... ' You need to look at consuming QUERYENDSESSION in WndProc to do what you want
' Declaration: ' ------------
Private Shared WM_QUERYENDSESSION As Integer = &H11
' Paste in the following sub: ' --------------------------
#Region "Window Proc (SUB)"
<System.Security.Permissions.PermissionSetAttribut e(System.Security.Permissi ons.SecurityAction.Demand, Name:="FullTrust")> _ Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) ' Listen for operating system messages If m.Msg = WM_QUERYENDSESSION Then ' Handle the closing of your program here. If you have the form
closing to the System Tray then you need to handle the Form_Closing event (see below) End If ' Handle the message MyBase.WndProc(m) End Sub
#End Region
' When I minimise to System Tray, I set Cancel = True, but when Windows is closing down, I make sure that Cancel = False allowing the closing of the application. This can be down with a simple boolean value:
Dim blnIsWindowsClosing As Boolean = False
' In Form Closing: ' -----------------
If blnIsWindowsClosing = True Then e.Canel = True else e.Cancel = False End If
' So, now in the QUERYENDSESSION (WndProc), set : ' ----------------------------------------------------------
blnIsWindowsClosing = True
' Obviously, if you do not want to minimise to System Tray then just use
the QUERYENDSESSION constant & the WndProc sub
' Its as easy as that. It works for Logoff, Restart & Shutdown
I hope this helps
Crouchie1998 BA (HONS) MCP MCSE
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jonathan Heath |
last post by:
Hi all,
I have created an ASP script that enters data into an Access Database.
My problem is that I'd like this script to run when the computer is shutdown
or the user logs off.
I think...
|
by: JonBoy |
last post by:
Is it possible to put the logoff/shutdown/restart buttons on an ASP page or something similar? If so can anyone point me in the direction of some code please or where I can read how to do it
...
|
by: Jammie |
last post by:
Hi all,
I have a major problem with my application. For some reason on win9x my
application will not exit properly when the user shuts down there system.
This doesnt seem to be a problem on XP....
|
by: pamelafluente |
last post by:
Hi Guys,
I have a small application which uses a NotifyIcon. The user can set a
flag (PreventClosing ) so that when he clicks on the form-cancel button
"X", the program will instead be...
|
by: rdemyan via AccessMonster.com |
last post by:
I have a forced logoff routine in place that works well unless an Access
messagebox is showing in the front-end that the routine is trying to shut
down. It doesn't work use Access commands to...
|
by: erdem |
last post by:
Hi,
I have a console program that handles events such as SHUTDOWN, LOGOFF.
I took the source code from
http://www.codeproject.com/win32/console_event_handling.asp
What I try to do after...
|
by: mikemiller.innova |
last post by:
I developed a C# Windows App that requires a user to input their real
name and what they did to the server while they were online.
I am going to launch the app att shutdown via a logoff script.
...
|
by: CyberSoftHari |
last post by:
I want to get applications running (Showing) in Task bar (and show those applications running) and Cancel windows LogOff, Shutdown, Restart when user try to Click windows LogOff, Shutdown, Restart
|
by: Clemente |
last post by:
Hi,
We have a VB.Net application that is sleeping until it receives a
logoff/shutdown event. We want the application running on Vista and
XP.
When the application receives those events it has...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |