// After you exit the SQL "Service Manager" test, you can still find that the SQL server software is installed on the current machine.
// Add a reference space for Windows Services: system. Service. process. dll
Using system. serviceprocess;
// Button event:
Private void button#click (Object sender, system. eventargs E)
{
If (existsqlserverservice ())
{
MessageBox. Show ("SQL Server software has been installed on your computer ");
}
Else
{
MessageBox. Show ("SQL Server software has not been installed on this computer ");
}
}
// Call the judgment Function
# region custom check whether the SQL2000 method is installed on the current machine
Public static bool existsqlserverservice ()
{< br> bool existflag = false;
servicecontroller [] service = servicecontroller. getservices ();
for (INT I = 0; I {< br> If (Service [I]. displayname. tostring () = "MSSQLServer")
{< br> existflag = true;
}< BR >}< br> return existflag;
}< BR ># endregion