Csharp/C#教程:C#中实现在32位、64位系统下自动切换不同的SQLite dll文件分享

直接上代码:

usingSystem; usingSystem.Collections.Generic; usingSystem.Windows.Forms; usingSystem.Management; usingSystem.IO; namespaceSqliteAuto { staticclassProgram { ///<summary> ///应用程序的主入口点。 ///</summary> [STAThread] staticvoidMain() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); stringdll32=System.Windows.Forms.Application.StartupPath+"\lib\SQLite32.DLL"; stringdll64=System.Windows.Forms.Application.StartupPath+"\lib\SQLite64.DLL"; stringdllpath=System.Windows.Forms.Application.StartupPath+"\System.Data.SQLite.dll"; if(Detect32or64()=="32") { //do32bitthings. try { using(FileStreamfs=File.Create(dllpath)){} File.Copy(dll32,dllpath,true); } catch { Console.WriteLine("ERR"); } } elseif(Detect32or64()=="64") { //do64bitthings try { using(FileStreamfs=File.Create(dllpath)){} File.Copy(dll64,dllpath,true); } catch { Console.WriteLine("ERR"); } } Application.Run(newForm1()); } privatestaticstringDetect32or64() { try { stringaddressWidth=String.Empty; ConnectionOptionsmConnOption=newConnectionOptions(); ManagementScopemMs=newManagementScope("\\localhost",mConnOption); ObjectQuerymQuery=newObjectQuery("selectAddressWidthfromWin32_Processor"); ManagementObjectSearchermSearcher=newManagementObjectSearcher(mMs,mQuery); ManagementObjectCollectionmObjectCollection=mSearcher.Get(); foreach(ManagementObjectmObjectinmObjectCollection) { addressWidth=mObject["AddressWidth"].ToString(); } returnaddressWidth; } catch(Exceptionex) { Console.WriteLine(ex.ToString()); returnString.Empty; } } } } 您可能感兴趣的文章:C#操作SQLite方法实例详解C#中使用SQLite数据库的方法介绍ASP.NET(C#)中操作SQLite数据库实例C#操作SQLite数据库方法小结(创建,连接,插入,查询,删除等)C#实现Excel导入sqlite的方法C#基于SQLiteHelper类似SqlHelper类实现存取Sqlite数据库的方法C#简单访问SQLite数据库的方法(安装,连接,查询等)c#几种数据库的大数据批量插入(SqlServer、Oracle、SQLite和MySql)C#解决SQlite并发异常问题的方法(使用读写锁)C#SQLite执行效率的优化教程

标签: dll文件 系统 SQL dl 自动 ite te dll

C++生成和解析XML文件的讲解

C++实现十六进制字符串转换成int整形值的示例

上述就是C#学习教程:C#中实现在32位、64位系统下自动切换不同的SQLite dll文件分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/907231.html

(0)
上一篇 2021年10月24日
下一篇 2021年10月24日

精彩推荐