7,776
社区成员
发帖
与我相关
我的任务
分享
//杀死打开的word进程
Process myProcess = new Process();
Process[] wordProcess = Process.GetProcessesByName("winword");
try
{
foreach (Process pro in wordProcess) //这里是找到那些没有界面的Word进程
{
IntPtr ip= pro.MainWindowHandle;
string str = pro.MainWindowTitle; //发现程序中打开跟用户自己打开的区别就在这个属性
//用户打开的str 是文件的名称,程序中打开的就是空字符串
if (string.IsNullOrEmpty(str))
{
pro.Kill();
}
}
}
catch (Exception ex)
{
ex.ToString();
}