本文整理汇总了C#中Microsoft.Quit方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Quit方法的具体用法?C# Microsoft.Quit怎么用?C# Microsoft.Quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft
的用法示例。
在下文中一共展示了Microsoft.Quit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dispose
/// <summary>
/// 释放内存
/// </summary>
public void Dispose(Microsoft.Office.Interop.Excel._Worksheet CurSheet, Microsoft.Office.Interop.Excel._Workbook CurBook, Microsoft.Office.Interop.Excel._Application CurExcel)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(CurSheet);
CurSheet = null;
CurBook.Close(false, mValue, mValue);
System.Runtime.InteropServices.Marshal.ReleaseComObject(CurBook);
CurBook = null;
CurExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(CurExcel);
CurExcel = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
catch (System.Exception ex)
{
// HttpContext.Current.Response.Write("在释放Excel内存空间时发生了一个错误:" + ex);
}
finally
{
foreach (System.Diagnostics.Process pro in System.Diagnostics.Process.GetProcessesByName("Excel"))
//if (pro.StartTime < DateTime.Now)
pro.Kill();
}
System.GC.SuppressFinalize(this);
}
示例2: fullTextCheck
public Microsoft.Office.Interop.Word.Application fullTextCheck(string filePath, Boolean isPathChanged, string keyWord, string oldKeyWord, Boolean isKeyWordChanged, Microsoft.Office.Interop.Word.Application word)
{
Boolean extraSituation = false;
try
{
if (word.Documents.Count == 0)
{
word = openDocument(filePath, word);
extraSituation = true;
}
else if (isPathChanged)//路径改变则关掉之前文档,打开新的文档
{
word.Documents.Close(WdSaveOptions.wdDoNotSaveChanges, Type.Missing, Type.Missing);
word.Quit();
word = openDocument(filePath, word);
}
}
catch
{
word = new Microsoft.Office.Interop.Word.Application();
word = openDocument(filePath, word);
extraSituation = true;
}
Selection currentSelect = word.Selection;
if (isKeyWordChanged || isPathChanged || extraSituation) //关键字改变的话需要还原文档
{
if (oldKeyWord != "")
{
restoreDocument(oldKeyWord, currentSelect);
}
replace(keyWord, currentSelect);//替换关键字为高亮显示
}
return word;
}
示例3: KillProcessExcel
/// <summary>
/// Kill process excel
/// </summary>
/// <param name="application"></param>
public static void KillProcessExcel(Microsoft.Office.Interop.Excel.Application application)
{
application.Quit();
int hWnd = application.Application.Hwnd;
uint processID;
System.Runtime.InteropServices.Marshal.ReleaseComObject(application);
GetWindowThreadProcessId((IntPtr)hWnd, out processID);
Process[] procs = Process.GetProcessesByName("EXCEL");
foreach (Process p in procs)
{
if (p.Id == processID)
p.Kill();
}
}
示例4: KillAllExcel
public bool KillAllExcel(Microsoft.Office.Interop.Excel.Application excelApp)
{
try
{
if (excelApp != null)
{
excelApp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
//释放COM组件,其实就是将其引用计数减1
//System.Diagnostics.Process theProc;
foreach (System.Diagnostics.Process theProc in System.Diagnostics.Process.GetProcessesByName("EXCEL"))
{
//先关闭图形窗口。如果关闭失败.有的时候在状态里看不到图形窗口的excel了,
//但是在进程里仍然有EXCEL.EXE的进程存在,那么就需要释放它
if (theProc.CloseMainWindow() == false)
{
theProc.Kill();
}
}
excelApp = null;
return true;
}
}
catch
{
return false;
}
return true;
}
示例5: DocumentPrintOut
private static void DocumentPrintOut(Microsoft.Office.Interop.Word.Application oWordApplic, Microsoft.Office.Interop.Word.Document doc)
{
object append = Missing.Value;
object background = true;
object wdPrintAllDocument = Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintAllDocument;
object copies = 1;
object wdPrintAllPages = Microsoft.Office.Interop.Word.WdPrintOutPages.wdPrintAllPages;
object printToFile = false;
object collate = false;
object obj9 = append;
object manualDuplexPrint = false;
object printZoomColumn = 1;
object printZoomRow = 1;
doc.PrintOut(ref background, ref append, ref wdPrintAllDocument, ref append, ref append, ref append, ref append, ref copies, ref append, ref wdPrintAllPages, ref printToFile, ref collate, ref append, ref manualDuplexPrint, ref printZoomColumn, ref printZoomRow, ref append, ref append);
object wdDoNotSaveChanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
object wdOriginalDocumentFormat = Microsoft.Office.Interop.Word.WdOriginalFormat.wdOriginalDocumentFormat;
oWordApplic.Quit(ref wdDoNotSaveChanges, ref wdOriginalDocumentFormat, ref append);
Marshal.ReleaseComObject(doc);
Marshal.ReleaseComObject(oWordApplic);
doc = null;
oWordApplic = null;
}
示例6: SaveDocument
private void SaveDocument(Microsoft.Office.Interop.Word.Document wordDocument, Microsoft.Office.Interop.Word.ApplicationClass wordApp, string filePath)
{
object Visible = false;
object missing = System.Reflection.Missing.Value;
Object Nothing = System.Reflection.Missing.Value;
object Save_FileName = filePath;
//保存模板文件
wordDocument.SaveAs(ref Save_FileName, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref Visible,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing);
//关闭wordDoc文档对象
wordDocument.Close(ref Nothing, ref Nothing, ref Nothing);
wordDocument = null;
//关闭wordApp组件对象
wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
}