执行code,当我的窗体关闭我的、窗体、code

由网友(月亮快递员)分享简介:我的程序使得在注册表中的一些变化,而它的运行,如果他们没有正确回滚,他们可能会造成用户的一些问题。例如,他们可能不能够使用他们的互联网连接。My program makes some changes in the registry while it's running, and if they are not pro...

我的程序使得在注册表中的一些变化,而它的运行,如果他们没有正确回滚,他们可能会造成用户的一些问题。例如,他们可能不能够使用他们的互联网连接。

My program makes some changes in the registry while it's running, and if they are not properly rolled back, they might cause the user some problems. FOr example, they might not be able to use their Internet connection.

所以,我需要确保当他们关闭应用程序,我回到一切恢复正常。要做到这一点,我需要知道,当他们有pressed形式的关闭按钮。我该怎么办呢?有没有办法,我可以处理一个事件?

So I need to make sure that when they close the application, I return everything back to normal. To do this, I need to know when they have pressed the Close button of the form. How can I do that? Is there an event that I can handle?

推荐答案

我认为你需要的是不能访问的关闭按钮,而是进入的事件的被解雇的形式时,是封闭的。

I think that what you need is not access to the close button, but rather access to the event which is fired when the form is closed.

从这 previous SO后,你可能需要的是一样的东西因此:

Taken from this previous SO post, what you might need is something like so:

void FormClosed(object sender, FormClosedEventArgs e)
{
    // do something useful
}
阅读全文

相关推荐

最新文章