473,406 Members | 2,620 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,406 software developers and data experts.

Detecting Windows Shutdown in Access 97

Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #1
8 2989
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:

Not easily.
The next best thing is to detect that your app is closing. You do this
by opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.

-Tom.

Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.


Nov 12 '05 #2
In article <c5********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.


Not easily.
The next best thing is to detect that your app is closing. You do this
by opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.


Thanks, but that is what we are effectively doing now. I did not make
myself clear. We are trying to differentiate between a shutdown of the
application initiated by a user and that initiated by Windows.

In the first case we want to ask a question "Do you really want to close
down.." while in the second we want to close down the application
without any further questions.

I was hoping some API was available.

The only solution I can think of is to ask the user the question in a
form which has a short time-out and then continues with the shutdown if
there is no user intervention.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #3
You would have to subclass the app and watch for the appropriate system
shut down Message. I've seen such code over in VB land which would work
with Access directly. A google search should yield several solutions.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Les Desser" <le****@[127.0.0.1]> wrote in message
news:Kz**************@dessergroup.com...
In article <c5********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm ifthey want to shut the application. If the user is not at his desk andpower fails and the UPS instructs Windows to close, then Windows willnot shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.
Not easily.
The next best thing is to detect that your app is closing. You do thisby opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.


Thanks, but that is what we are effectively doing now. I did not make
myself clear. We are trying to differentiate between a shutdown of

the application initiated by a user and that initiated by Windows.

In the first case we want to ask a question "Do you really want to close down.." while in the second we want to close down the application
without any further questions.

I was hoping some API was available.

The only solution I can think of is to ask the user the question in a
form which has a short time-out and then continues with the shutdown if there is no user intervention.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))


Nov 12 '05 #4
On Sat, 4 Oct 2003 21:37:12 +0100, Les Desser <le****@[127.0.0.1]>
wrote:

Steven is right. When I commented "not easily" I meant you'll need a
DLL that hooks the message queue and checks for shutdown messages.
These should be available online. A few years back the company now
called Infragistics had one - they called it something like a message
spy.

-Tom.

In article <c5********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
On Thu, 2 Oct 2003 13:43:02 +0100, Les Desser <le****@[127.0.0.1]>
wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.


Not easily.
The next best thing is to detect that your app is closing. You do this
by opening a hidden form as the first form when starting the app. It
will be the last one to close, so that's when you perform some
last-second cleanup.


Thanks, but that is what we are effectively doing now. I did not make
myself clear. We are trying to differentiate between a shutdown of the
application initiated by a user and that initiated by Windows.

In the first case we want to ask a question "Do you really want to close
down.." while in the second we want to close down the application
without any further questions.

I was hoping some API was available.

The only solution I can think of is to ask the user the question in a
form which has a short time-out and then continues with the shutdown if
there is no user intervention.


Nov 12 '05 #5
In article <jb********************************@4ax.com>, Tom van
Stiphout <to*****@no.spam.cox.net> writes
Steven is right. When I commented "not easily" I meant you'll need a
DLL that hooks the message queue and checks for shutdown messages.
These should be available online. A few years back the company now
called Infragistics had one - they called it something like a message
spy.


Thanks to you both - I will investigate
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #6

<snip>

Thanks to you both - I will investigate
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))


I could do with something similar - if you find the info please share it
with the group. I will do the same.

Nick
Nov 12 '05 #7
One way is to use Visual Basic to detect the shutdown and perhaps
update a record in a table when it detects it. Your Access program
could keep checking for the record in the table (eg via a timer)

VB has a query unload event that can tell what causes the unload.

For an example of this, goto:

http://www.aylott.com.au/software.htm

and download the Windows Utilities (WINUTILS). Look for QRYEXIT in the
help file. This simply displays a dialog when it detects a Windows
shutdown but could be enhanced, of course...

Les Desser <le****@[127.0.0.1]> wrote:
Is there any way to detect within A97 when Windows is trying to shut
down, so I can close down the application gracefully?

We currently have a trap in the main menu asking the user to confirm if
they want to shut the application. If the user is not at his desk and
power fails and the UPS instructs Windows to close, then Windows will
not shut down till the Access dialog is dismissed. Result = a flat
battery and a crashed PC.

Thanks.

,-._|\ David Aylott (Author of Access Version Checking utility)
/ Oz \ ng***@bigfoot.com (Melbourne, Australia)
\_,--.x/ Shareware, FAQ, hints & tips at:
v http://www.aylott.com.au/
Nov 12 '05 #8
In article <vo************@corp.supernews.com>, Nick Marshall
<Nick@Marshall.?.COM.invalid> writes

I could do with something similar - if you find the info please share it
with the group. I will do the same.

I have done some hunting in Google and MS KB without any luck.

I'm not sure of your need, but what I have done will suffice for me at
the moment.

I have changed my "Do you really want to close down this application"
question in the Unload event from a Msgbox to loading a form in Dialog
mode. This form has a Timer Interval of 5 seconds and gives the user
the option to cancel.

After the five seconds, the form closes and the calling form can detect,
via a Global variable, whether a user cancel was requested or not. If
not it allows the unload to continue.
==========
An other method I just thought of, based on a suggestion by Tom van
Stiphout and his comment that forms are closed in the reverse order of
their being opened (I presume that is what he meant with:- the first
hidden form will be last to close).:-

1. Open the master menu

2. Open a hidden form.

3. If the master menu detects a closedown it checks if the hidden form
is still open. If it is then the user has requested a closedown on the
master menu. If it is not then it is a system initiated closedown.

I have two problems though. First, if a user closes the application not
via the master menu but via the Widowns close (X) it will look like a
system closedown. The second is that when I run a test by doing a
log-off with several windows open in my application, it is the master
menu (opened first) that detects the closedown while the other windows
stay open.
--
Les Desser
(The Reply-to address IS correct - hope Swen ignores it))
Nov 12 '05 #9

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

Similar topics

1
by: Tim Gosselin | last post by:
I am writing a tcp tunnel but cannot find a way of detecting when a socket shuts down its read end without writing to the socket. For testing the write end of the remote endpoint I just do a: if...
5
by: Rich | last post by:
I have a simple, single threaded program in C++ that runs as Idle priority. The program creates some data which needs dumping to file if the computer is shutdown or logged out. At the moment...
6
by: Bruce Vander Werf | last post by:
I am using the asynchronous send/receive methods of the Socket class. When the remote end closes the socket, the callback for receive is called and EndReceive returns 0. Socket.Connected still...
7
by: Aarti | last post by:
I have written a windows service that needs to perform certain functions only if a User is logged in. The problem I am running into is that I get an error if the computer is in the process of being...
5
by: David Griffin | last post by:
I have a console application that spawns off several C# threads. It needs to react to shutdown of the system by performing some end of program activities including writing some files and closing...
2
by: Paul Steele | last post by:
Some time ago I tracked down the code for detecting the shutdown event within a C# program. I tested it, it worked, and I moved on. However, I just discovered that the code is no longer working,...
2
by: Brian Worth | last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0 was able to shut down or restart the (windows XP) machine using a series of API calls. (Getlasterror, GetCurrentProcess,...
6
sashi
by: sashi | last post by:
Shut down Windows For various reasons you may require a shut down of Windows to happen programmatically. For instance if the installation of your program requires system reconfiguration. The...
0
by: =?Utf-8?B?SiBTdHJlZ2Vy?= | last post by:
I am using C#.NET 2003, and my form has a WndProc override to capture the windows messages. I can halt the shutdown the user initiated and run my code, but I wanted to see if there was a way to...
0
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
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
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,...

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.