国产精品免费无遮挡无码永久视频-国产高潮视频在线观看-精品久久国产字幕高潮-国产精品99精品无码视亚
電子工程網(wǎng)
標(biāo)題:
C#下對(duì)DLL加載的異常捕捉代碼
[打印本頁(yè)]
作者:
hotpower
時(shí)間:
2009-4-3 00:05
標(biāo)題:
C#下對(duì)DLL加載的異常捕捉代碼
public bool DllLoadResult = false;
private void Form1_Load(object sender, EventArgs e)
{//delphi一般在此初始化
try
{
DllLoadResult = InitializeWinIo();//加載WinIO
}
catch (System.Exception error)
{//WinIO加載失敗異常處理
MessageBox.Show(error.Message, "系統(tǒng)提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
if (!DllLoadResult)
{//加載WinIO失敗
Application.Exit();//退出系統(tǒng),同Close()方法
}
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{//捕捉窗體Close事件,關(guān)閉窗口時(shí)提示
if (!DllLoadResult || MessageBox.Show("請(qǐng)您確認(rèn)是否退出(Y/N)", "系統(tǒng)提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
if (DllLoadResult)
{
try
{
ShutdownWinIo();//卸載WinIO
}
catch (System.Exception error)
{//WinIO卸載失敗異常
MessageBox.Show(error.Message, "系統(tǒng)提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
e.Cancel = false;//允許退出系統(tǒng)
}
else
{
e.Cancel = true;//阻止退出系統(tǒng)
}
}
歡迎光臨 電子工程網(wǎng) (http://m.4huy16.com/)
Powered by Discuz! X3.4