From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbccp32/odbccp32.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index 95bfb90781e..5eb70bd60b5 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -713,20 +713,29 @@ BOOL WINAPI SQLGetInstalledDrivers(char *buf, WORD size, WORD *sizeout)
static HKEY get_privateprofile_sectionkey(LPCWSTR section, LPCWSTR filename) { - HKEY hkey, hkeyfilename, hkeysection; + HKEY hkeysection; LONG ret; + WCHAR *regpath;
- if (RegOpenKeyW(HKEY_CURRENT_USER, odbcW, &hkey)) + regpath = malloc ( (wcslen(L"Software\ODBC\") + wcslen(filename) + wcslen(L"\") + + wcslen(section) + 1) * sizeof(WCHAR)); + if (!regpath) return NULL;
- ret = RegOpenKeyW(hkey, filename, &hkeyfilename); - RegCloseKey(hkey); + wcscpy(regpath, L"Software\ODBC\"); + wcscat(regpath, filename); + wcscat(regpath, L"\"); + wcscat(regpath, section); + + if ((ret = RegOpenKeyW(HKEY_CURRENT_USER, regpath, &hkeysection)) != ERROR_SUCCESS) + { + ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, regpath, &hkeysection); + } + free(regpath); + if (ret) return NULL;
- ret = RegOpenKeyW(hkeyfilename, section, &hkeysection); - RegCloseKey(hkeyfilename); - return ret ? NULL : hkeysection; }