Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 检查excel 2010比特率_C#_Visual Studio_Excel_Vsto_Office Interop - Fatal编程技术网

C# 检查excel 2010比特率

C# 检查excel 2010比特率,c#,visual-studio,excel,vsto,office-interop,C#,Visual Studio,Excel,Vsto,Office Interop,是否可以使用在kernel32.dll中定义的getBinaryType()函数来获取office 2010比特度 [DllImport("kernel32.dll")] static extern bool GetBinaryType(string lpApplicationName, out uint lpBinaryType); uint type; GetBinaryType("applicationName",out type); 我曾尝试使用下面所述的应用程序类,但有时会失败

是否可以使用在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的bitness?

我要做的是

1) 打开以下注册表项:

HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer
(guid表示“Excel应用程序”)

2) 从键的默认值中提取Excel的.EXE路径(要删除所有命令行参数)

3) 在路径上使用
GetBinaryType

我要做的是

1) 打开以下注册表项:

HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer
(guid表示“Excel应用程序”)

2) 从键的默认值中提取Excel的.EXE路径(要删除所有命令行参数)


3) 在路径上使用
GetBinaryType

您是否正在使用Excel运行进程中?在这种情况下,,只需检查System.IntPtr.Size。@SimonMourier:我认为System.IntPtr.Size将返回操作系统位,但可以在64位计算机上安装office 32位,因此在这种情况下,我希望使用System.IntPtr.sizeSystem.IntPtr.Size返回执行进程位。@SimonMourier:是,您是对的,但我希望在安装程序类中使用此功能。与excel应用程序没有交互。GetBinaryType()可以工作,但存在鸡和蛋的问题。如果不知道.exe文件是64位版本还是32位版本,则不知道该文件安装在何处。文件系统重定向使其更加麻烦。您是否正在使用Excel运行进程中?在这种情况下,,只需检查System.IntPtr.Size。@SimonMourier:我认为System.IntPtr.Size将返回操作系统位,但可以在64位计算机上安装office 32位,因此在这种情况下,我希望使用System.IntPtr.sizeSystem.IntPtr.Size返回执行进程位。@SimonMourier:是,您是对的,但我希望在安装程序类中使用此功能。与excel应用程序没有交互。GetBinaryType()可以工作,但存在鸡和蛋的问题。如果不知道.exe文件是64位版本还是32位版本,则不知道该文件安装在何处。文件系统重定向使其更加麻烦。在某些计算机上,即使office 2007和office 2010安装在该计算机上,我也无法找到此注册表项。奇怪。这可能是X64/X86的问题。关于
HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID\{00024500-0000-0000-C000-0000000000 46}\LocalServer
(对于32位程序)?此注册表项不存在于32位系统中,但正如您所说,它存在于64位系统中。您是对的,这可能是32位和64位系统问题。但我现在可以假设在x86机器中存在“HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-0000000000 46}\LocalServer”,在x64位中存在“HKEY_LOCAL_machine\SOFTWARE\Wow6432Node\CLASSES\CLSID\{00024500-0000-0000-C000”-‌​0000000000 46}\LocalServer“将存在。在某些计算机上,我无法找到此注册表项,即使该计算机上安装了office 2007和office 2010。奇怪。这可能是X64/X86的问题。关于
HKEY\U LOCAL\U MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID\{00024500-0000-0000-C000-0000000000 46}\LocalServer
(对于32位程序)?此注册表项不存在于32位系统中,但正如您所说,它存在于64位系统中。您是对的,这可能是32位和64位系统问题。但我现在可以假设在x86机器中存在“HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-0000000000 46}\LocalServer”,在x64位中存在“HKEY_LOCAL_machine\SOFTWARE\Wow6432Node\CLASSES\CLSID\{00024500-0000-0000-C000”-‌​0000000000 46}\LocalServer“将存在。