The usual way of doing this would be to use SQLDMO (also known as SQL-DMO,
search Google for both). The following give you an exemple in .NET for
discovering servers and database using SQLDMO:
http://www.codeproject.com/cs/database/spgen.asp
However, using SQLDMO doesn't mean that you can necessarily discover all
servers on your local machine or onto the network. SQLDMO will look for
things like Alias but to get at all the serverss, the discovery service must
be enabled (SQL-2005) as well as other services for the other machines on
the network (Browser service?).