473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Urgent: XP, Vista logoff application (WM_QUERYENDSESSION)

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 to show a message
box, so the user can answer Yes or No, and then let the logoff/
shutdown process continues.

We are doing this in VB.Net listening to WM_QUERYENDSESSION message.

We are having the following problems:

.. - It doesnt work in Vista.
- In XP, when the application receives the WM_QUERYENDSESSION
message it shows the System End Task window for this application,
before showing the message box we want.

We are using this VB . Net code:

---------------------------
Private Shared WM_QUERYENDSESSION As Integer = &H11
Private Shared systemShutdown As Boolean = False

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
'MessageBox.Show("queryendsession: this is a logoff,
shutdown, or reboot")
systemShutdown = True
End If
' If this is WM_QUERYENDSESSION, the closing event should be
raised in the base WndProc.
MyBase.WndProc(m)
End Sub 'WndProc
-------------------------
Private Sub frmMsg_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (systemShutdown) Then
' Reset the variable because the user might cancel the
shutdown.
systemShutdown = False
If (System.Windows.Forms.DialogResult.Yes =
MessageBox.Show("My application", "Abort logoff?",
MessageBoxButtons.YesNo)) Then
e.Cancel = True
Else
e.Cancel = False
End If
End If
End Sub
-----------------------

Why this behaviour? Any ideas?

TIA,

Clemente
Portugal
Nov 29 '07 #1
1 5290

"Clemente" <cl*************@gmail.comwrote in message
news:3f**********************************@x69g2000 hsx.googlegroups.com...
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 to show a message
box, so the user can answer Yes or No, and then let the logoff/
shutdown process continues.

We are doing this in VB.Net listening to WM_QUERYENDSESSION message.

We are having the following problems:

. - It doesnt work in Vista.
- In XP, when the application receives the WM_QUERYENDSESSION
message it shows the System End Task window for this application,
before showing the message box we want.

We are using this VB . Net code:

---------------------------
Private Shared WM_QUERYENDSESSION As Integer = &H11
Private Shared systemShutdown As Boolean = False

Protected Overrides Sub WndProc(ByRef m As
System.Windows.Forms.Message)
If m.Msg = WM_QUERYENDSESSION Then
'MessageBox.Show("queryendsession: this is a logoff,
shutdown, or reboot")
systemShutdown = True
End If
' If this is WM_QUERYENDSESSION, the closing event should be
raised in the base WndProc.
MyBase.WndProc(m)
End Sub 'WndProc
-------------------------
Private Sub frmMsg_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (systemShutdown) Then
' Reset the variable because the user might cancel the
shutdown.
systemShutdown = False
If (System.Windows.Forms.DialogResult.Yes =
MessageBox.Show("My application", "Abort logoff?",
MessageBoxButtons.YesNo)) Then
e.Cancel = True
Else
e.Cancel = False
End If
End If
End Sub
-----------------------

Why this behaviour? Any ideas?

TIA,

Clemente
Portugal
Not sure why you need to monitor the WndProc. In the FormClosingEventArgs
there is an indication as to why the form is being closed. Check it and if
it is system shutdown then show the message and cancel if the user wants.

Hope this helps
Lloyd Sheen

Nov 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John | last post by:
Hi all, I have recently been approached to build a piece of software which automatically logs off a user after a set time has elapsed. The company wants someone to give a user access to a...
1
by: VM | last post by:
I'm trying to debug an application in the VC dot net compiler and when I begin, I get the error: Unable to start debugging Unable to start program 'c:\myApp\PROGRAM\myApp.exe' 'G:\Program...
1
by: dumindaj | last post by:
I have problems running my Java Swing application remotely on a Linux machine. The application takes 20/30s to respond to events and painting takes considerable time. This is not a special case...
14
by: Keith | last post by:
I have an MDE application used by several hundred people in different parts of the world. The majority of users are of lesser experience computer experience. The app consists of a frontend (MDE)...
1
by: =?Utf-8?B?VG9teTExMDI=?= | last post by:
Hi. I want to run ClickOnce Application as Administrator in Vista I think that the best way for users to elevate privilege is embed Application Manifest. But, I don't know how to elevate...
0
by: Jean-Marc Blaise | last post by:
Hi folks, I am looking for a WAS application that would run on the SAMPLE db2 database (version 9.1), just for testing WAS ND 6.1. Apparently, all sample applications on Websphere are NOT...
2
by: Vighneswar | last post by:
Hi All Please let me know is there any way to clear the address bar history ( Typed URLs) of Firefox browser programmatically. Deleting 'index.dat' under profiles folder of firefox will delete...
1
by: cg2002 | last post by:
Hi, How can I abort the shutdown/logoff in windows vista? Using the WM_QUERYENDSESSION only works in XP. TIA Carlos
0
by: Nelson R. | last post by:
Greetings, I've already posted this message on aspnet.security group (think its related to security issues), but since didn't get any response, I post it here. -- I have a problem, and been...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.