Upstream is failing since it's only looking in HKEY_USER, and your code isn't correcting that.
This patch isn't trying to fix that. The reason it's only looking under HKEY_USER is because SQLConfigDataSource() sets the config mode to ODBC_ADD_DSN for a user DSN before calling the setup function, which is correct AFAICT. This is the same before and after this patch.