国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#中實現在32位、64位系統下自動切換不同的SQLite dll文件

2020-01-24 02:26:43
字體:
來源:轉載
供稿:網友

直接上代碼:

using System;using System.Collections.Generic;using System.Windows.Forms;using System.Management;using System.IO;namespace SqliteAuto{  static class Program  {    /// <summary>    /// 應用程序的主入口點。    /// </summary>    [STAThread]    static void Main()    {          Application.EnableVisualStyles();      Application.SetCompatibleTextRenderingDefault(false);      string dll32 = System.Windows.Forms.Application.StartupPath + "http://lib//SQLite32.DLL";      string dll64 = System.Windows.Forms.Application.StartupPath + "http://lib//SQLite64.DLL";      string dllpath = System.Windows.Forms.Application.StartupPath + "http://System.Data.SQLite.dll";      if (Detect32or64() == "32")      {        // do 32bit things.        try        {          using (FileStream fs = File.Create(dllpath)) { }          File.Copy(dll32, dllpath, true);        }          catch        {          Console.WriteLine("ERR");        }        }      else if (Detect32or64() == "64")      {        //do 64bit things        try        {          using (FileStream fs = File.Create(dllpath)) { }          File.Copy(dll64, dllpath, true);        }          catch        {          Console.WriteLine("ERR");        }      }      Application.Run(new Form1());    }      private static string Detect32or64()    {      try      {        string addressWidth = String.Empty;        ConnectionOptions mConnOption = new ConnectionOptions();        ManagementScope mMs = new ManagementScope("http:////localhost", mConnOption);        ObjectQuery mQuery = new ObjectQuery("select AddressWidth from Win32_Processor");        ManagementObjectSearcher mSearcher = new ManagementObjectSearcher(mMs, mQuery);        ManagementObjectCollection mObjectCollection = mSearcher.Get();        foreach (ManagementObject mObject in mObjectCollection)        {          addressWidth = mObject["AddressWidth"].ToString();        }        return addressWidth;      }      catch (Exception ex)      {        Console.WriteLine(ex.ToString());        return String.Empty;      }    }  }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 孙吴县| 新平| 德江县| 石楼县| 开江县| 自贡市| 清丰县| 石狮市| 新和县| 从化市| 康保县| 南陵县| 通化市| 察隅县| 正阳县| 会泽县| 巴中市| 获嘉县| 夏津县| 龙门县| 信阳市| 商城县| 黔西| 河南省| 增城市| 定日县| 连平县| 满洲里市| 东平县| 泾阳县| 城固县| 肥乡县| 贡山| 杂多县| 台东县| 许昌县| 平昌县| 卢龙县| 香港 | 墨竹工卡县| 桃江县|