用C#编写excel线程

编程入门 行业动态 更新时间:2024-10-24 04:35:37
本文介绍了用C#编写excel线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道如何确定目标PC上是否安装了32位或64位Ace OLEDB驱动程序,然后定制我的程序的32位或64位版本,从而用OLEDB编写出出色的表现. 当前在具有64位ACE的64位办公室上,我需要将Visual Studio中的配置从x86更改为x64,反之亦然. 是否有任何方法可以检测32/64位安装,您是否需要在安装项目中编写脚本,还是可以动态编写代码以更改32/64版本? 谢谢, Jase

Hi, I would like to know how to determine if the Ace OLEDB Driver is 32 or 64bit installed on the target PC and then tailor the 32 or 64 bit build of my program which writes to excel with OLEDB. Currently on 64 bit office with 64bit ACE I need to change the configuration in visual studio from x86 to x64 and vice versa. Is there any method to detect 32/64bit installation and do you need in the setup project to write a script or can you dynamically write code to alter the 32/64 build that way. Thanks, Jase

推荐答案

如果将应用编译为目标任何CPU",它将在32位proc上运行32位,在64位上运行64位procs. 如果将应用程序编译为以"x86"为目标,则无论运行什么操作系统,它都将仅运行32位. 但是,如果您编译"Any CPU",则由于无法在同一进程中合并32位和64位代码,因此检查安装内容是毫无意义的.但是,您应该检查代码以什么位数运行.通过检查IntPtr的大小,这很容易做到.如果您的代码运行的是32位,则为4字节宽;如果是64位的,则为8字节.那么它只是使用正确的连接字符串. 同样,您无需检查安装了什么Office或驱动程序,而无需检查代码的运行方式. If you compile your app to target "Any CPU" it''ll run 32-bit on 32-bit procs and 64-bit on 64-bit procs. If you compile your app to target "x86", it''ll run 32-bit only no matter what O/S it''s running on. But, if you compile "Any CPU", since you can''t combine 32- and 64-bit code in the same process it''s kind of pointless to check to see what''s installed. You should, though, be checking to see what bitness your code is running as. That''s easy enough to do by checking the sizeof an IntPtr. It''ll be 4 bytes wide if your code is running 32-bit and 8 bytes if 64-bit. Then it''s just using the correct connection string. Again, you don''t check what Office or driver is installed, you check what your code is running as.

更多推荐

用C#编写excel线程

本文发布于:2023-11-05 12:39:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560868.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   excel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!