ODBCINST.INI = Driver Infomration. ODBC.INI = DSN information.
Drivers have to be registered with the system, so will be under LOCAL_MACHINE.
Tested with both MySQL and Postgresql ODBC drivers which supply the ODBCINST.INI parameter when requesting driver information.
-- v2: odbccp32: SQLGet/WritePrivateProfileStringW support driver config
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/odbccp32/odbccp32.c | 14 ++++++++------ dlls/odbccp32/tests/misc.c | 5 +++++ 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c index 90a7517b957..fd02391a384 100644 --- a/dlls/odbccp32/odbccp32.c +++ b/dlls/odbccp32/odbccp32.c @@ -734,10 +734,11 @@ int WINAPI SQLGetPrivateProfileStringW(LPCWSTR section, LPCWSTR entry, if (!defvalue || !buff) return 0;
- if (config_mode == ODBC_USER_DSN) - sectionkey = get_privateprofile_sectionkey(HKEY_CURRENT_USER, section, filename); - else if (config_mode == ODBC_SYSTEM_DSN) + /* odbcinit.ini is only for drivers, so default to local Machine */ + if (!wcsicmp(filename, L"ODBCINST.INI") || config_mode == ODBC_SYSTEM_DSN) sectionkey = get_privateprofile_sectionkey(HKEY_LOCAL_MACHINE, section, filename); + else if (config_mode == ODBC_USER_DSN) + sectionkey = get_privateprofile_sectionkey(HKEY_CURRENT_USER, section, filename); else { sectionkey = get_privateprofile_sectionkey(HKEY_CURRENT_USER, section, filename); @@ -1812,10 +1813,11 @@ BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry return FALSE; }
- if (config_mode == ODBC_USER_DSN) - ret = RegCreateKeyW(HKEY_CURRENT_USER, L"Software\ODBC", &hkey); - else if (config_mode == ODBC_SYSTEM_DSN) + /* odbcinit.ini is only for drivers, so default to local Machine */ + if (!wcsicmp(lpszFilename, L"ODBCINST.INI") || config_mode == ODBC_SYSTEM_DSN) ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, L"Software\ODBC", &hkey); + else if (config_mode == ODBC_USER_DSN) + ret = RegCreateKeyW(HKEY_CURRENT_USER, L"Software\ODBC", &hkey); else { ret = RegCreateKeyW(HKEY_CURRENT_USER, L"Software\ODBC", &hkey); diff --git a/dlls/odbccp32/tests/misc.c b/dlls/odbccp32/tests/misc.c index 81c66a44a24..0b982642177 100644 --- a/dlls/odbccp32/tests/misc.c +++ b/dlls/odbccp32/tests/misc.c @@ -317,6 +317,11 @@ static void test_SQLGetPrivateProfileStringW(void) WCHAR buffer[256] = {0}; LONG reg_ret;
+ /* Get Driver Information - Currently under wine we dont have any default drivers. */ + ret = SQLGetPrivateProfileStringW(L"SQL Server", L"SQLlevel" , L"99", buffer, 256, L"ODBCINST.INI"); + todo_wine ok(ret == 1, "SQLGetPrivateProfileStringW returned %d\n", ret); + todo_wine ok(!lstrcmpW(buffer, L"1"), "incorrect string '%s'\n", wine_dbgstr_w(buffer)); + lstrcpyW(buffer, L"wine"); ret = SQLGetPrivateProfileStringW(NULL, L"testing", L"default", buffer, 256, L"ODBC.INI"); ok(ret == 0, "SQLGetPrivateProfileStringW returned %d\n", ret);
Hans Leidekker (@hans) commented about dlls/odbccp32/tests/misc.c:
WCHAR buffer[256] = {0}; LONG reg_ret;
- /* Get Driver Information - Currently under wine we dont have any default drivers. */
- ret = SQLGetPrivateProfileStringW(L"SQL Server", L"SQLlevel" , L"99", buffer, 256, L"ODBCINST.INI");
- todo_wine ok(ret == 1, "SQLGetPrivateProfileStringW returned %d\n", ret);
- todo_wine ok(!lstrcmpW(buffer, L"1"), "incorrect string '%s'\n", wine_dbgstr_w(buffer));
You can set driver information and then query it. You should also make sure this is using the ODBC_USER_DSN config mode.
On Fri Aug 16 09:36:43 2024 +0000, Hans Leidekker wrote:
You can set driver information and then query it. You should also make sure this is using the ODBC_USER_DSN config mode.
Something like this [misc.diff](/uploads/08b85ef62b1fbad8a609bb5db4ae298e/misc.diff)