There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware missing monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
windows xp shutdown


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
DataBase's Avatar
Computer Specs
Senior Member with 312 posts.
 
Join Date: Jan 2004
Experience: Intermediate
07-Jul-2004, 05:10 AM #1
windows xp shutdown
Hello all i havent asked a question for a while so i thought i should get some help with something. I want to make a program using Visual Basic 6, the program should load up at windows start up, this i ok as i have found out how to write to the appropriate place in the registry to achive this. BUT when the user starts to shut down the computer i want my program to detect this event and do something, basically i have to make something that tells the user some facts about their computer usage eg how long they were on it and stuff like that. when they shut down i ant my program to know this is happening and display a message. how came i detect windows shutdown please, is this possible?

Thank you
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
07-Jul-2004, 08:14 AM #2
The only way that I can think of to do that is to detect the shutdown of that program. You can put the code in the Form_Terminate event and when Windows closes the program in preparation for a system shutdown, display the information that you want. The only problem with this is that Windows may think that your application is hung and display a "this program has not responded to the end task command" message.

If you figure out another way to do this, I'd like to know about it too.
DataBase's Avatar
Computer Specs
Senior Member with 312 posts.
 
Join Date: Jan 2004
Experience: Intermediate
07-Jul-2004, 03:19 PM #3
Well i dont really know of any other ways of testing this condition, but your way works brilliantly. On computing.net i asked the same question and someone said the same a you did but using the QueryUnload event, i used it to test the computer shutdown thus

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
if UnloadMode = 2 then
blah blah blah
end if
End Sub

the 2 indicates the computer causing the shutdown rather than the user exiting the program.

its cool, thankyou for your help
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
07-Jul-2004, 03:51 PM #4
No problem -- I have a similar situation with a vendor's code hanging the shutdown on NT. I had to write code for them to wait for the startup of the SQL Server service before launching their daemon process and it doesn't shut down without using task manager or the "this program has not responded ..." popup. The senior developer at the vendor site suggested that I write something to detect the NT shutdown and stop his process when it occured. Seems to me that I shouldn't have to do that but oh well.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:32 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.