How SharePoint farm locates its configuration database

Did you ever wonder how SharePoint farm locates its configuration database. It’s not in a web.config or in any other configuration files. It’s actually a lot simpler than it probably should have been. SharePoint actually stores the connection to the configuration database in the registry (see dsn key). 

SharePoint 2007: HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\Secure\ConfigDB

SharePoint 2010: HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDB

SharePoint 2013: HKLM\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\15.0\Secure\ConfigDB (this one I have not actually checked, but I am betting it’s still there)

Scary, isn’t it?