Пример #1
0
 /// <summary>
 /// Try to detect current host application version. (All MS-Office products supports the version property except for Access9 aka Access 2000)
 /// </summary>
 /// <returns>version or null if its failed to detect</returns>
 protected internal double?TryGetApplicationVersion()
 {
     try
     {
         if (_ownerApplication.EntityIsAvailable("Version"))
         {
             object   result  = _ownerApplication.Invoker.PropertyGet(_ownerApplication, "Version");
             string[] version = Convert.ToString(result).Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
             if (version.Length > 1)
             {
                 return(Convert.ToDouble(version[0] + "." + version[1], CultureInfo.InvariantCulture));
             }
             else
             {
                 return(Convert.ToDouble(version[0], CultureInfo.InvariantCulture));
             }
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
Пример #2
0
 /// <summary>
 /// Try to detect current host application version. (All MS-Office products supports the version property except for Access 9 aka Access 2000)
 /// </summary>
 /// <returns>version or null if its failed to detect</returns>
 public static double?TryGetApplicationVersion(ICOMObject applcationInstance)
 {
     try
     {
         if (applcationInstance.EntityIsAvailable("Version"))
         {
             object   result  = applcationInstance.Invoker.PropertyGet(applcationInstance, "Version");
             string[] version = Convert.ToString(result).Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
             if (version.Length > 1)
             {
                 return(Convert.ToDouble(version[0] + "." + version[1], CultureInfo.InvariantCulture));
             }
             else
             {
                 return(Convert.ToDouble(version[0], CultureInfo.InvariantCulture));
             }
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }