Programmatically list the local instances of SQL Server

Long back I wrote a post about Enumerating Instances of SQL Server using C. But this code snippet will not list your sql server instances installed on your system. Here is the code snippet using Windows registry which will list all the local instances of sql server. Happy Programming