I realize this isn't showing you how to do it yourself programatically, but I've always liked using the Microsoft Assessment and Planning (MAP) toolkit. It shows me all instances, organizes them into a very detailed spreadsheet (SQL Version, service pack level, number of CPUs, edition, Windows edition/version, drives with space info, etc.)
I blogged about the tool a couple years ago when I first discovered it (pardon the excitement in the post ;-) ) Downfalls are - it has to be installed, Office 2007 needed and you need to have higher permissions (Preferably domain admin, especially if you don't know what boxes SQL is installed on) but you can always have a sysadmin run it and then you can use that Spreadsheet to list your SQL instances and even import it into a database used for database administration.
SQL Server DBA
Blog - www.straightpathsql.com/blog