473,396 Members | 1,722 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,396 software developers and data experts.

Preventing Logoff / Shutdown until C# Windows App is closed

I developed a C# Windows App that requires a user to input their real
name and what they did to the server while they were online.

I am going to launch the app att shutdown via a logoff script.

I want to prevent the computer from logging off or shutting down until
the app is closed.

The best example I have is when you have an unsaved notepad.exe
document open and logoff or shutdown, an End Program dialog pops up
that says "The system cannot end this program because it is waiting for
a response from you". The computer will sit there forever waiting for
user response. I want that to happen with my app so they are forced to
enter data before the logoff/shutdown process continues.

How can I do this?

Jan 19 '07 #1
2 8319
Anyone?

mi***************@gmail.com wrote:
I developed a C# Windows App that requires a user to input their real
name and what they did to the server while they were online.

I am going to launch the app att shutdown via a logoff script.

I want to prevent the computer from logging off or shutting down until
the app is closed.

The best example I have is when you have an unsaved notepad.exe
document open and logoff or shutdown, an End Program dialog pops up
that says "The system cannot end this program because it is waiting for
a response from you". The computer will sit there forever waiting for
user response. I want that to happen with my app so they are forced to
enter data before the logoff/shutdown process continues.

How can I do this?
Jan 23 '07 #2
I had to figure it out myself...

With a form called 'Form1', you can use this code to do it:

(bSubmitted is a boolean that gets set to TRUE after the app submits
an entry)

private void Form1_FormClosing(object sender,
FormClosingEventArgs e)
{
if (bSubmitted == false)
{
if (MessageBox.Show("You are closing this app without
submitting an entry.\n\nAre you sure you wish to exit without
submitting?", "Warning: Not Submitted", MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Stop) == DialogResult.Yes)
return;
else
e.Cancel = true;
}
}

On Jan 22, 3:53 pm, mikemiller.inn...@gmail.com wrote:
Anyone?

mikemiller.inn...@gmail.com wrote:
I developed a C# Windows App that requires a user to input their real
name and what they did to the server while they were online.
I am going to launch the app att shutdown via a logoff script.
I want to prevent the computer from logging off or shutting down until
the app is closed.
The best example I have is when you have an unsaved notepad.exe
document open and logoff or shutdown, an End Program dialog pops up
that says "The system cannot end this program because it is waiting for
a response from you". The computer will sit there forever waiting for
user response. I want that to happen with my app so they are forced to
enter data before the logoff/shutdown process continues.
How can I do this?- Hide quoted text -

- Show quoted text -

Mar 6 '07 #3

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

Similar topics

8
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think...
7
by: JonBoy | last post by:
Is it possible to put the logoff/shutdown/restart buttons on an ASP page or something similar? If so can anyone point me in the direction of some code please or where I can read how to do it ...
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
by: Jm | last post by:
Hi All I have a simple vb.net app that once run for some reason does not allow me to log off or shutdown the pc ? When i try to do so it will close my app and then will only shutdown or logoff...
3
by: Mantorok | last post by:
Hi all Is there any way to prevent a user from closing down an application (via task manager)? Thanks Kev
0
by: sam | last post by:
I have a vb.net app that runs without a visible window. When the user logs off or attempts a shutdown, the app is not quitting and prevents the logoff/shutdown until the task is killed. Is there...
3
by: Bill Davidson | last post by:
All: I have a problem in which a worker thread in my (.dll) assembly isn't allowing the main (.exe) assembly from terminating. Here's the scenario: 1) App.Exe is launched. 2) App.Exe calls...
1
by: CyberSoftHari | last post by:
I want to get applications running (Showing) in Task bar (and show those applications running) and Cancel windows LogOff, Shutdown, Restart when user try to Click windows LogOff, Shutdown, Restart
1
by: cg2002 | last post by:
Hi, How can I abort the shutdown/logoff in windows vista? Using the WM_QUERYENDSESSION only works in XP. TIA Carlos
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.