• 获取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

  • 相关阅读:
    SVG Stroke属性
    C# 线程同步之排它锁/Monitor监视器类
    在Mac OS X Yosemite 10.10.3 中搭建第一个 ASP.NET 5 Web 项目
    jquery 之 Deferred 使用与实现
    jQuery 之 Callback 实现
    在解决方案中所使用 NuGet 管理软件包依赖
    下载和使用 Open XML PowerTools
    下载和编译 Open XML SDK
    Open XML SDK 在线编程黑客松
    VS2013 解决方案文件结构分析
  • 原文地址:https://www.cnblogs.com/swarb/p/9924261.html
Copyright © 2020-2023  润新知