From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbccp32/odbccp32.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index dbcc7ae5383..5b38ba471cf 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -38,7 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(odbc);
/* Registry key names */ static const WCHAR drivers_key[] = {'S','o','f','t','w','a','r','e','\','O','D','B','C','\','O','D','B','C','I','N','S','T','.','I','N','I','\','O','D','B','C',' ','D','r','i','v','e','r','s',0}; -static const WCHAR odbcW[] = {'S','o','f','t','w','a','r','e','\','O','D','B','C',0}; static const WCHAR odbcini[] = {'S','o','f','t','w','a','r','e','\','O','D','B','C','\','O','D','B','C','I','N','S','T','.','I','N','I','\',0}; static const WCHAR odbcdrivers[] = {'O','D','B','C',' ','D','r','i','v','e','r','s',0}; static const WCHAR odbctranslators[] = {'O','D','B','C',' ','T','r','a','n','s','l','a','t','o','r','s',0}; @@ -1814,7 +1813,7 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry { static const WCHAR empty[] = {0}; LONG ret = ERROR_FILE_NOT_FOUND; - HKEY hkey = NULL, hrootkey; + HKEY hkey = NULL; WCHAR *regpath;
clear_errors(); @@ -1850,7 +1849,13 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey); }
- hrootkey = config_mode == ODBC_SYSTEM_DSN ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + /* Only create the key if it doesn't exist. */ + if (!hkey) + { + HKEY hrootkey = config_mode == ODBC_SYSTEM_DSN ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + + ret = RegCreateKeyW(hrootkey, regpath, &hkey); + }
free(regpath);
@@ -1862,28 +1867,6 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry ret = RegSetValueExW(hkey, lpszEntry, 0, REG_SZ, (BYTE*)empty, sizeof(empty)); RegCloseKey(hkey); } - else if ((ret = RegCreateKeyW(hrootkey, odbcW, &hkey)) == ERROR_SUCCESS) - { - HKEY hkeyfilename; - - if ((ret = RegCreateKeyW(hkey, lpszFilename, &hkeyfilename)) == ERROR_SUCCESS) - { - HKEY hkey_section; - - if ((ret = RegCreateKeyW(hkeyfilename, lpszSection, &hkey_section)) == ERROR_SUCCESS) - { - if(lpszString) - ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR)); - else - ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)empty, sizeof(empty)); - RegCloseKey(hkey_section); - } - - RegCloseKey(hkeyfilename); - } - - RegCloseKey(hkey); - }
return ret == ERROR_SUCCESS; }