国产精品人成在线播放新网站,欧洲吸奶大片在线看,亚洲欧洲成人a∨在线,国产18禁黄网站免费观看

微信號(hào):
當(dāng)前位置:首頁 > 資訊文摘 > 新聞資訊

c#清除word進(jìn)程和excel進(jìn)程

2015/10/28 10:29:25

        #region 清除word進(jìn)程
        /**//// <summary>
        /// 清除word進(jìn)程
        /// </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進(jìn)程
        /**//// <summary>
        /// 清除excel進(jìn)程
        /// </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

相關(guān)新聞: