zoukankan      html  css  js  c++  java
  • 获取office版本

       /// <summary>
            /// office版本
            /// </summary>
            public enum OfficeVersion { Office2007,Office2003}    

      /// <summary>
            /// 获取office版本
            /// </summary>
            /// <returns></returns>
            public static OfficeVersion GetOfficeVersion()
            {
                OfficeVersion version = OfficeVersion.Office2003;
                Microsoft.Win32.RegistryKey regKey = null;
                Microsoft.Win32.RegistryKey regSubKey = null;
                try
                {
                    regKey = Microsoft.Win32.Registry.LocalMachine;
                    if (regSubKey == null)
                    {//office2007
                        regSubKey = regKey.OpenSubKey(@"SOFTWAREMicrosoftOffice12.0CommonInstallRoot", false);
                        version= OfficeVersion.Office2007;
                    }
                    if (regSubKey == null)
                    {//Office2003
                        regSubKey = regKey.OpenSubKey(@"SOFTWAREMicrosoftOffice11.0CommonInstallRoot", false);
                        version= OfficeVersion.Office2003;
                    }
                }
                catch (System.Security.SecurityException ex)
                {
                    throw new System.Security.SecurityException("您没有读取注册表的权限", ex);
                }
                catch (Exception ex)
                {
                    throw new Exception("读取注册表出错!", ex);
                }
                if (regKey != null)
                {
                    regKey.Close();
                    regKey = null;
                }

                if (regSubKey != null)
                {
                    regSubKey.Close();
                    regSubKey = null;
                }
                return version;
            }

    http://bbs.csdn.net/topics/350108050

    http://hi.baidu.com/guog_/item/26a2e825f94c76d7a517b65c

  • 相关阅读:
    VMware 克隆一个虚拟机(win7)
    HDU 5695 Gym Class (拓扑排序、贪心、优先队列)
    HDU2647 Reward (拓扑排序、反向建图)
    HDU 3342 Legal or Not (拓扑排序、有向图是否存在环)
    Vue框架简介及简单使用
    Linux文件常用指令
    Linux系统相关命令
    Linux关机指令详解
    linux目录结构
    Linux用户相关命令
  • 原文地址:https://www.cnblogs.com/swarb/p/9924261.html
Copyright © 2011-2022 走看看