#region 清除word进程
/**//// <summary>
/// 清除word进程
/// </summary>
public static void KillWordProcess()
{
System.Diagnostics.Process[] myPs;
myPs = System.Diagnostics.Process.GetProcesses();
foreach( System.Diagnostics.Process p in myPs )
{
if( p.Id != 0 )
{
string myS = "WINWORD.EXE" + p.ProcessName + " ID:" + p.Id.ToString();
try
{
if( p.Modules != null )
if( p.Modules.Count > 0 )
{
System.Diagnostics.ProcessModule pm = p.Modules[0];
myS += "/n Modules[0].FileName:" + pm.FileName;
myS += "/n Modules[0].ModuleName:" + pm.ModuleName;
myS += "/n Modules[0].FileVersionInfo:/n" + pm.FileVersionInfo.ToString();
if( pm.ModuleName.ToLower() == "winword.exe" )
p.Kill();
}
}
catch
{ }
finally
{
}
}
}
}
#endregion
#region 清除excel进程
/**//// <summary>
/// 清除excel进程
/// </summary>
public static void KillExcelProcess()
{
System.Diagnostics.Process[] myPs;
myPs = System.Diagnostics.Process.GetProcesses();
foreach( System.Diagnostics.Process p in myPs )
{
if( p.Id != 0 )
{
string myS = "excel.EXE" + p.ProcessName + " ID:" + p.Id.ToString();
try
{
if( p.Modules != null )
if( p.Modules.Count > 0 )
{
System.Diagnostics.ProcessModule pm = p.Modules[0];
myS += "/n Modules[0].FileName:" + pm.FileName;
myS += "/n Modules[0].ModuleName:" + pm.ModuleName;
myS += "/n Modules[0].FileVersionInfo:/n" + pm.FileVersionInfo.ToString();
if( pm.ModuleName.ToLower() == "excel.exe" )
p.Kill();
}
}
catch
{ }
finally
{
}
}
}
}
#endregion