基本上我有一个使用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