在主窗体的closing事件中,加入如下代码: if ( MessageBox.Show("要重新启动嘛?","提示", MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Question) == DialogResult.Yes) System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
MessageBoxIcon.Question) == DialogResult.Yes) System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
{ try
{
throw new Exception("HI");
using (CreateDevice frm = new CreateDevice())
{
if (!frm.InitializeGraphics()) // Initialize Direct3D
{
MessageBox.Show("Could not initialize Direct3D. This tutorial will exit.");
return;
}
frm.Show(); // While the form is still valid, render and process messages
while(frm.Created)
{
frm.Render();
Application.DoEvents();
}
}
}
catch
{
MessageBox.Show("重启啦");
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
}
}