Check if SQL Server is installed on a machine through C#

后端 未结 2 1555
太阳男子
太阳男子 2020-12-16 02:31

I am making an application which is a user interface to access 2 types of databases - SQLite and SQL Server.

The thing is, SQLite doesnt need to be \"installed\

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 02:58

    If your app is installed on the machine in question, you could inspect the registry using something similar to this:

    using Microsoft.Win32; 
    RegistryKey RK = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\MICROSOFT\Microsoft SQL Server");
        if(RK != null)
        {
           // It's there 
        }
        else
        {
           // It's not there 
        }
    

提交回复
热议问题