Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am Making attendance System so I'm take the time of log in and the time of log out when user click on Login and Logout button .

but i have another scenario if power off on PC this mean i will store the time of log in and the time of log out will not set so i want to consider the time of power off to be the time of log out how i can get this time.
Posted

You will probably need to implement OnShutdown()[^] method, or similar.
 
Share this answer
 
Comments
Mehdi Gholam 22-Nov-11 9:19am    
5'ed
Honeyboy_20 22-Nov-11 9:36am    
Does Shutdown like power off plugin
Richard MacCutchan 22-Nov-11 10:02am    
Sorry, but I don't understand what you mean.
fjdiewornncalwe 22-Nov-11 10:12am    
I think the OP wants to know if they can track the situation where there is sudden power loss of some kind as opposed to a controlled reboot/shutdown.
Richard MacCutchan 22-Nov-11 10:35am    
Thanks, got the idea.
Create a windows service and log the information you require to an external database on a server machine.

Simple Windows Service Sample[^]
 
Share this answer
 
If I understand your question correctly, I think you want to be able to trace the time at which a sudden power loss, hard shut down occurs on the system whereby there won't be an entry in the system event logs. The only suggestion I would have is that you use Mehdi's suggestion to create a simple service that writes something every minute or so to an external database by which you will then be accurate to within a minute if such an event occurs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900