Hi all,
I'm trying to capture the WM_QUERYENDSESS ION message in a Windows Form
and prevent the session from shutting down. I overrode the Form's
WndProc method to do this, but I'm completely dumbfounded, because it
seems to work on every Windows computer I can find in the office and at
home (Win98 and WinXP machines), _except_ my development machine. On my
machine, the Form's WndProc method never even receives the
WM_QUERYENDSESS ION message, and so Windows shuts down. I'm running
Windows XP Professional Service Pack 2, and I'm guessing it might be
caused by a bug in SP2 or some small change to the shutdown protocol,
but I won't rule out other possibilities. In testing, I stripped
everything from the Form code except for the WndProc method and still
no dice. Here's the WndProc I'm using:
Protected Overrides Sub WndProc(ByRef m As
System.Windows. Forms.Message)
Select Case m.Msg
Case &H11 'WM_QUERYENDSES SION
MsgBox("WM_QUER YENDSESSION received")
'Stop the shutdown by returning 0
m.Result = IntPtr.Zero
Exit Sub
End Select
MyBase.WndProc( m)
End Sub
Microsoft docs say the WndProc method corresponds exactly to the WinAPI
WindowProc function, so I take that to mean that VB.NET will not filter
any messages before WndProc is called. I know the form's message pump
gets started, because in other tests I added code to the event handlers
and form events were raised without a hitch. I also know it's not a
VB.NET bug, because I wrote code to do the same thing in VB6 and it
also never receives the WM_QUERYENDSESS ION message on shutdown. I
thought it might be the case that another app gets the
WM_QUERYENDSESS ION and returns 0, and so my app never receives the
message, but that can't be it AFAIK, because the system always just
abruptly shuts down; my app never displays the message box on my
machine. And yes, I compiled the code and ran the actual EXE; I didn't
run the code from the IDE. I'm at a complete loss, because as I
mentioned, the code seems to work great on any computer except my own.
Even weirder: I just ran the code one more time on my machine, and it
worked...I didn't touch the source code at all, I just re-ran the EXE
that I had previously compiled and which wasn't working before.
Any other ideas as to what would prevent an app from receiving a
WM_QUERYENDSESS ION on system shutdown besides another app processing
the message first and returning 0?
--
Mike S 0 1432 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ralph |
last post by:
I used to have Visual Basic .net std. 2003 installed on WinXP SP1A. But I
found it too hard to upgrade WinXP to SP2. Now, I do have WinXP SP2
installed, but I am having problems installing Visual Basic .net standard
2003. Not installing Visual Basic at the WinXP SP1A level - was the only way
I found that I could
install WinXPSP2.
My computer was purchased with WinXP SP1 Professional. I also have
Norton Internet Security and Norton...
|
by: Macadair |
last post by:
I develop mid-range multi-user applications for a large site. Currently
Win98 and Office97 are the standards used however we are slowly moving to
WinXP. Due to the site upgrade cost, we are staying with Office97 for a
little longer. This means we will have Win98 and WinXP PC's running
Access97.
When I compile an Access97 application on a Win98 PC, the resultant .mde
functions correctly on both Win98 and WinXP PC's running Access97....
|
by: Frank Jiao |
last post by:
I can get my local IPv6 address in Win2003 use the source code as below:
string localName = Dns.GetHostName();
string address = "";
string scopeId = "";
IPHostEntry hostEntry = Dns.Resolve( localName );
foreach (IPAddress curAdd in hostEntry.AddressList)
{
if(curAdd.AddressFamily.ToString() ==
|
by: quilkin |
last post by:
Hi
When I use the WM_QUERYENDSESSION event to prevent closing of my app when
Windows is shut down, I get the 'windows forms parking window' appearing
which is very confusing for users.
Any ideas how to stop this?
|
by: |
last post by:
I have earlier used an HttpModule that did URL rewrites on the BeginRequest
event.
Now I am trying to use the same module in a different application on a new
and upgraded machine (winxp sp2).
The Module is registered via Web.config. The registration is OK. When asking
for an existing .aspx page, the eventhandler is called as it should.
HOWEVER - if the request url is for a non-existant file, I get a 404 - file
| |
by: James Cooke |
last post by:
Hi all,
I want to catch a duplicate key exception. I do not want to provide that
verbose message from the MSSQL server - I would put a user friendly message
out, like
"The item you have added already exists in the database. Please change
the description and try to save again."
instead of
|
by: daniel |
last post by:
I use a simple program to illustrate the problem:
import logging
def foo() :
raise ValueError("foo")
if __name__ == "__main__" :
try :
foo()
|
by: Frank |
last post by:
My program gets a WM_QUERYENDSESSION message and asks the user if it is OK
to shutdown.
While he's thinking about it, Windows displays a box saying the program is
not responding.
If the user clicks Cancel the shutdown is canceled.
My program receives a WM_ENDSESSION message and tells the user that the
shutdown has been canceled.
|
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 to show a message
box, so the user can answer Yes or No, and then let the logoff/
shutdown process continues.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |