Is it possible to get office 2010 bitness using getBinaryType() function which is defined in kernel32.dll something like this.
[DllImport("kernel32.dll")]
static extern bool GetBinaryType(string lpApplicationName, out uint lpBinaryType);
uint type;
GetBinaryType("applicationName",out type);
I have tried using application class as stated below but sometimes it will fail.
public static ExcelVersion GetExcelVersion(object applicationClass)
{
if (applicationClass == null)
throw new ArgumentNullException("applicationClass");
PropertyInfo property = applicationClass.GetType().GetProperty("HinstancePtr", BindingFlags.Instance | BindingFlags.Public);
if (property == null)
return ExcelVersion.Excel;
return (System.Runtime.InteropServices.Marshal.SizeOf(property.GetValue(applicationClass, null)) == 8) ? ExcelVersion.Excel2010_64 : ExcelVersion.Excel2010_32;
}
Is there any another way to detect office 2010 bitness?
What I would do is
1) open the following registry key:
(the guid means “Excel Application”)
2) extract Excel’s .EXE path from the key’s default value (you want to remove all command line arguments)
3) use
GetBinaryTypeon the path.