基本上我有一個使用Excel應用程序編寫的程序。C#如何阻止用戶使用程序創建的Excel應用程序
運行我的程序時,如果用戶試圖打開任何Excel文件,該文件在我的程序創建的Excel實例上打開。
我想這與excel打開 「Excel.exe」的現有實例有關。
當我的程序退出時,它會導致殭屍excel進程。
我想要做的是隱藏我的excel實例被用戶使用。 (或任何其他解決方案的情況)
我試圖谷歌的東西出來,但沒有到目前爲止。
我的代碼看起來像這樣。
foreach (string strFileName in this.m_ListRequestFileNames)
{
object misVal = System.Reflection.Missing.Value;
try
{
if (Common.IsOpened(strFileName) == true)
{
this.m_ParentWnd.Log(strFileName + " is in use by another program." + Environment.NewLine);
continue;
}
this.m_xlWBook = this.m_xlApp.Workbooks.Open(strFileName, 3, true, misVal, misVal, misVal, misVal, misVal, misVal, false, misVal, misVal, misVal, misVal, misVal);
if (Make(ref m_xlWBook, m_strDstPath, ref m_ListIgnoreSheetNames) != true)
{
this.m_ParentWnd.Log("-!- Error while making " + m_xlWBook.Name + " into a csv file" + Environment.NewLine);
continue;
}
this.m_ParentWnd.Log("Completed " + m_xlWBook.Name + Environment.NewLine);
}
catch (System.Exception e)
{
m_ParentWnd.Log(e.ToString());
}
this.m_xlWBook.Close(false, null, null);
}
this.m_xlApp.Quit();
Common.releaseObject(this.m_xlApp);
這是一個Web應用程序運行在服務器或桌面客戶端應用程序? – 2010-07-27 03:56:17
這是一個客戶端應用程序。 – Die4ACause 2010-07-27 04:59:57