Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/odbccp32/odbccp32.c | 6 +++++- dlls/odbccp32/tests/misc.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index 4ad51df..be68e6a 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -1600,6 +1600,7 @@ BOOL WINAPI SQLWriteFileDSN(LPCSTR lpszFileName, LPCSTR lpszAppName, BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry, LPCWSTR lpszString, LPCWSTR lpszFilename) { + static const WCHAR empty[] = {0}; LONG ret; HKEY hkey;
@@ -1623,7 +1624,10 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry
if ((ret = RegCreateKeyW(hkeyfilename, lpszSection, &hkey_section)) == ERROR_SUCCESS) { - ret = RegSetValueExW(hkey_section, lpszEntry, 0, REG_SZ, (BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR)); + 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); }
diff --git a/dlls/odbccp32/tests/misc.c b/dlls/odbccp32/tests/misc.c index 8a16a9e..be3873ac 100644 --- a/dlls/odbccp32/tests/misc.c +++ b/dlls/odbccp32/tests/misc.c @@ -171,6 +171,9 @@ static void test_SQLWritePrivateProfileString(void) { HKEY hkey;
+ ret = SQLWritePrivateProfileString("wineodbc", "testing" , NULL, "odbc.ini"); + ok(ret, "SQLWritePrivateProfileString failed\n"); + reg_ret = RegOpenKeyExW(HKEY_CURRENT_USER, odbc_key, 0, KEY_READ, &hkey); ok(reg_ret == ERROR_SUCCESS, "RegOpenKeyExW failed\n"); if(reg_ret == ERROR_SUCCESS)