Per determinare via codice se sul vostro computer sia installato SqlServer, basta controllare la seguente chiave di registro:
//C#
public static bool IsSqlServerInstalled()
{
bool isInstalled = false;
RegistryKey regSql = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion");
if (regSql.GetValue("CurrentVersion") != null)
{
isInstalled = true;
}
return isInstalled;
}
'VB
Public Shared Function IsSqlServerInstalled() As Boolean
Dim isInstalled As Boolean = False
Dim regSql As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion")
If regSql.GetValue("CurrentVersion") IsNot Nothing Then
isInstalled = True
End If
Return isInstalled
End Function
Nessun commento:
Posta un commento