是否可以使用在 kernel32.dll 中定义的getBinaryType()函数来获取 Office 2010的位数。
[DllImport("kernel32.dll")]
static extern bool GetBinaryType(string lpApplicationName, out uint lpBinaryType);
uint type;
GetBinaryType("applicationName",out type);
我曾尝试使用如下所述的应用程序类,但有时它会失败。
 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;
}
还有其他方法可以检测Office 2010位数吗?