zoukankan      html  css  js  c++  java
  • 通过访问注册表,表判断系统是否装excel

            #region 判断系统是否装excel
            /// <summary>
            /// 判断系统是否装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;
            }
            #endregion

            #region 判断系统是否装某版本的excel
            /// <summary>
            /// 判断系统是否装某版本的excel
            /// </summary>
            /// <param name="strVersion">版本号</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

  • 相关阅读:
    localhost和本机IP和127.0.0.1之间的区别
    git客户端msysGit和TortoiseGit使用
    JS正则
    css中外边距
    css定位浮动总结
    Teleport Ultra 抓包工具
    编程实践心得与设计思想
    Java 读写Properties配置文件
    如何成为一个优秀的DBA
    对DB2常见错误的列举以及破解方案
  • 原文地址:https://www.cnblogs.com/tangtang615/p/1402908.html
Copyright © 2011-2022 走看看