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

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

判斷是否安裝excel和word

2015/10/28 15:23:50

        #region 判斷系統(tǒng)是否裝excel
        /**//// <summary>
        /// 判斷系統(tǒng)是否裝excel
        /// </summary>
        /// <returns></returns>
        public static bool IsInstallExcel()
        {
            RegistryKey machineKey = Registry.LocalMachine;
            if( IsInstallExcelByVersion( "12.0", machineKey ) )
            {
                return true;
            }
            if( IsInstallExcelByVersion( "11.0", machineKey ) )
            {
                return true;
            }
            return false;
        }
        /**//// <summary>
        /// 判斷系統(tǒng)是否裝某版本的excel
        /// </summary>
        /// <param name="strVersion">版本號(hào)</param>
        /// <param name="machineKey"></param>
        /// <returns></returns>
        private static bool IsInstallExcelByVersion( string strVersion, RegistryKey machineKey )
        {
            try
            {
                RegistryKey installKey = machineKey.OpenSubKey( "Software" ).OpenSubKey( "Microsoft" ).OpenSubKey( "Office" ).OpenSubKey( strVersion ).OpenSubKey( "Excel" ).OpenSubKey( "InstallRoot" );
                if( installKey == null )
                {
                    return false;
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
        #endregion

        #region 判斷系統(tǒng)是否裝word
        /**//// <summary>
        /// 判斷系統(tǒng)是否裝word
        /// </summary>
        /// <returns></returns>
        public static bool IsInstallWord()
        {
            RegistryKey machineKey = Registry.LocalMachine;
            if( IsInstallExcelByVersion( "12.0", machineKey ) )
            {
                return true;
            }
            if( IsInstallExcelByVersion( "11.0", machineKey ) )
            {
                return true;
            }
            return false;
        }
        /**//// <summary>
        /// 判斷系統(tǒng)是否裝某版本的word
        /// </summary>
        /// <param name="strVersion">版本號(hào)</param>
        /// <param name="machineKey"></param>
        /// <returns></returns>
        private static bool IsInstallWordByVersion( string strVersion, RegistryKey machineKey )
        {
            try
            {
                RegistryKey installKey = machineKey.OpenSubKey( "Software" ).OpenSubKey( "Microsoft" ).OpenSubKey( "Office" ).OpenSubKey( strVersion ).OpenSubKey( "Word" ).OpenSubKey( "InstallRoot" );
                if( installKey == null )
                {
                    return false;
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
        #endregion  

相關(guān)新聞: