Question code to halt windows shut down or log off

Keanemeister

New member
Joined
Sep 16, 2009
Messages
1
Programming Experience
Beginner
Hi all, this is my first time to post so please be sure to tell me if i have this in the wrong area.

I work in IT in a firm that are rolling out a time management application on all PCs. In order to clock in/out a user must log into the application and click clock in/out. I want to build a very simple application that when a user goes to shut down or log out of their PC, a windows form will pop up asking them if they they want to clock out of the time management software (a reminder if they have forgotten to clock out and are heading home). On the form there will be two buttons, 'yes' and 'no'. If they click yes, the system shutdown or log off will be halted and the time management software application will open automatically. If they click no, the shutdown/logoff will proceed as normal.
I just need to know what i need to do to get the system shutdown/logoff to stop until either button is pressed and to stop totally if the 'yes' button is pressed. I am able to get the Time Management software to run on a button click but just not able to halt the shutdown or logoff?

Can anyone help me?

Thanks,

D
 
Use the main form's FormClosing event, you can get the reason from the e variable and you can also set e.cancel to prevent your app from closing.
 
Back
Top