欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#中實現(xiàn)在32位、64位系統(tǒng)下自動切換不同的SQLite dll文件

 更新時間:2014年09月06日 08:49:33   投稿:junjie  
這篇文章主要介紹了C#中實現(xiàn)在32位、64位系統(tǒng)下自動切換不同的SQLite dll文件,本文使用C#代碼實現(xiàn)DLL文件的切換,需要的朋友可以參考下

直接上代碼:

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 + "\\lib\\SQLite32.DLL";
      string dll64 = System.Windows.Forms.Application.StartupPath + "\\lib\\SQLite64.DLL";
      string dllpath = System.Windows.Forms.Application.StartupPath + "\\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("\\\\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;
      }
    }
  }
}

相關(guān)文章

  • C# 中的EventHandler實例詳解

    C# 中的EventHandler實例詳解

    本文通過案例實例介紹了c#中的eventhandler,需要的的朋友參考下吧
    2017-04-04
  • 一篇文章弄懂C#中的async和await

    一篇文章弄懂C#中的async和await

    這篇文章主要給大家介紹了如何通過一篇文章弄懂C#中async和await的相關(guān)資料,async和await相信大家應該不陌生,讓異步處理變得更友好,本文通過示例代碼介紹的非常詳細,需要的朋友可以參考下
    2021-07-07
  • Unity 按鈕事件封裝操作(EventTriggerListener)

    Unity 按鈕事件封裝操作(EventTriggerListener)

    這篇文章主要介紹了Unity 按鈕事件封裝操作(EventTriggerListener),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • C#實現(xiàn)用于生成條形碼的類

    C#實現(xiàn)用于生成條形碼的類

    這篇文章主要介紹了C#實現(xiàn)用于生成條形碼的類,涉及C#生成條形碼的原理與實現(xiàn)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-03-03
  • C#使用CefSharp控件實現(xiàn)爬蟲

    C#使用CefSharp控件實現(xiàn)爬蟲

    這篇文章介紹了C#使用CefSharp控件實現(xiàn)爬蟲的方法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-06-06
  • Unity3D控件Easytouch控制主角移動

    Unity3D控件Easytouch控制主角移動

    這篇文章主要為大家詳細介紹了Unity3D控件Easytouch控制主角移動,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-02-02
  • C#實現(xiàn)一個Word保護性模板文件

    C#實現(xiàn)一個Word保護性模板文件

    這篇文章主要為大家詳細介紹了C#如何實現(xiàn)一個Word保護性模板文件,文中的示例代碼講解詳細,具有一定的借鑒價值,需要的小伙伴可以參考一下
    2024-01-01
  • C#實現(xiàn)QQ窗口抖動效果

    C#實現(xiàn)QQ窗口抖動效果

    這篇文章主要為大家詳細介紹了C#實現(xiàn)QQ窗口抖動效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-11-11
  • c# 抓取Web網(wǎng)頁數(shù)據(jù)分析

    c# 抓取Web網(wǎng)頁數(shù)據(jù)分析

    通過程序自動的讀取其它網(wǎng)站網(wǎng)頁顯示的信息,類似于爬蟲程序。比方說我們有一個系統(tǒng),要提取BaiDu網(wǎng)站上歌曲搜索排名。分析系統(tǒng)在根據(jù)得到的數(shù)據(jù)進行數(shù)據(jù)分析。為業(yè)務提供參考數(shù)據(jù)。
    2008-11-11
  • 淺談C#索引器

    淺談C#索引器

    這篇文章主要簡單介紹C#索引器,索引器使你可從語法上方便地創(chuàng)建類、結(jié)構(gòu)或接口,以便客戶端應用程序可以像訪問數(shù)組一樣訪問它們。編譯器將生成一個 Item 屬性和適當?shù)脑L問器方法,在主要目標是封裝內(nèi)部集合或數(shù)組的類型中,常常要實現(xiàn)索引器,下面我們一起來看看具體內(nèi)容吧
    2021-11-11

最新評論