PC Review


Reply
Thread Tools Rate Thread

Detecting Shutdown.exe

 
 
=?Utf-8?B?Y2FzaGRlc2ttYWM=?=
Guest
Posts: n/a
 
      23rd Mar 2005
I want to detect when the users computer is going to close down so that I can
write all unfinished data to a file before closing down. Does anyone know
how this is done?
 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      23rd Mar 2005
What unfinished data are you talking about? You mean stuff that your own
application uses, or other applications.

There probably are ways of hooking the shutdown event, but could you just do
that when your program closes? If you are monitoring other applications,
then you might create like a Windows service or a NotifyIcon class that just
sites around waiting for some event to terminate their process, then save
all your data.

"cashdeskmac" <(E-Mail Removed)> wrote in message
news:9B697FF2-BBB0-41CD-9741-(E-Mail Removed)...
> I want to detect when the users computer is going to close down so that I

can
> write all unfinished data to a file before closing down. Does anyone know
> how this is done?



 
Reply With Quote
 
Michael A. Covington
Guest
Posts: n/a
 
      23rd Mar 2005
Shutdown will close your program. Simply set your program to save all its
data when it closes.

"cashdeskmac" <(E-Mail Removed)> wrote in message
news:9B697FF2-BBB0-41CD-9741-(E-Mail Removed)...
>I want to detect when the users computer is going to close down so that I
>can
> write all unfinished data to a file before closing down. Does anyone know
> how this is done?



 
Reply With Quote
 
J. Buelna - Houston, TX
Guest
Posts: n/a
 
      24th Mar 2005

"cashdeskmac" <(E-Mail Removed)> wrote in message
news:9B697FF2-BBB0-41CD-9741-(E-Mail Removed)...
>I want to detect when the users computer is going to close down so that I
>can
> write all unfinished data to a file before closing down. Does anyone know
> how this is done?



Hello cashdeskmac,

Here's how I've done it in the past.

Create a class with a static constructor that will hold a Check.IsSaved
property:

public Check
{
static Check() {}

private string _isSaved = "";
public bool IsSaved
{
set { _isSaved = value; }
get { return _isSaved; }
}
// other static check values...
}

Whenever data has changed, change the IsSaved property to false.
Whenever a file is saved, change the IsSaved status to true.
Finally, check the IsSaved property when the application is about to close
and take the appropriate action/inaction.

Handlers on component and application events will make this a snap.

J. Buelna - Houston, TX




 
Reply With Quote
 
J. Buelna - Houston, TX
Guest
Posts: n/a
 
      24th Mar 2005

"J. Buelna - Houston, TX" <jbuelna-(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
>
> "cashdeskmac" <(E-Mail Removed)> wrote in message
> news:9B697FF2-BBB0-41CD-9741-(E-Mail Removed)...
>>I want to detect when the users computer is going to close down so that I
>>can
>> write all unfinished data to a file before closing down. Does anyone
>> know
>> how this is done?

>
>
> Hello cashdeskmac,
>
> Here's how I've done it in the past.
>
> Create a class with a static constructor that will hold a Check.IsSaved
> property:
>
> public Check
> {
> static Check() {}
>
> private string _isSaved = "";
> public bool IsSaved
> {
> set { _isSaved = value; }
> get { return _isSaved; }
> }
> // other static check values...
> }
>
> Whenever data has changed, change the IsSaved property to false.
> Whenever a file is saved, change the IsSaved status to true.
> Finally, check the IsSaved property when the application is about to
> close and take the appropriate action/inaction.
>
> Handlers on component and application events will make this a snap.
>
> J. Buelna - Houston, TX
>



I initially intended to make a string property called Check.SaveStatus, but
instead went with a bool and forgot to change the type of the private field.
It should be:

private bool _isSaved = "";

J. Buelna - Houston, TX



 
Reply With Quote
 
J. Buelna - Houston, TX
Guest
Posts: n/a
 
      24th Mar 2005

"J. Buelna - Houston, TX" <jbuelna-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>
> "J. Buelna - Houston, TX" <jbuelna-(E-Mail Removed)> wrote in
> message news:e%(E-Mail Removed)...
>>
>> "cashdeskmac" <(E-Mail Removed)> wrote in message
>> news:9B697FF2-BBB0-41CD-9741-(E-Mail Removed)...
>>>I want to detect when the users computer is going to close down so that I
>>>can
>>> write all unfinished data to a file before closing down. Does anyone
>>> know
>>> how this is done?

>>
>>
>> Hello cashdeskmac,
>>
>> Here's how I've done it in the past.
>>
>> Create a class with a static constructor that will hold a Check.IsSaved
>> property:
>>
>> public Check
>> {
>> static Check() {}
>>
>> private string _isSaved = "";
>> public bool IsSaved
>> {
>> set { _isSaved = value; }
>> get { return _isSaved; }
>> }
>> // other static check values...
>> }
>>
>> Whenever data has changed, change the IsSaved property to false.
>> Whenever a file is saved, change the IsSaved status to true.
>> Finally, check the IsSaved property when the application is about to
>> close and take the appropriate action/inaction.
>>
>> Handlers on component and application events will make this a snap.
>>
>> J. Buelna - Houston, TX
>>

>
>
> I initially intended to make a string property called Check.SaveStatus,
> but instead went with a bool and forgot to change the type of the private
> field. It should be:
>
> private bool _isSaved = "";
>
> J. Buelna - Houston, TX
>
>



Der!!!!!!!!!!!!!!

private bool _isSaved = true; // assume that when the class is
initialized, no data has been entered.


J. Buelna - Houston, TX



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting the type of shutdown J Streger Microsoft Dot NET 0 28th Nov 2007 03:45 PM
Detecting system logoff/shutdown.... sam Microsoft VB .NET 0 30th May 2006 02:51 PM
RE: Detecting system shutdown from service. Mohamoss Microsoft C# .NET 0 6th Aug 2004 03:32 PM
Detecting Shutdown or Restart Jerry Camel Microsoft VB .NET 0 18th May 2004 10:20 PM
Detecting Windows shutdown Dave Townsend Microsoft Dot NET Framework Forms 8 1st Nov 2003 10:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:47 AM.