Commit 3136beda authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

odbccp32: Implement SQLRemoveDriver/SQLRemoveDriverW.

parent e96056a0
...@@ -1132,22 +1132,76 @@ BOOL WINAPI SQLRemoveDefaultDataSource(void) ...@@ -1132,22 +1132,76 @@ BOOL WINAPI SQLRemoveDefaultDataSource(void)
return FALSE; return FALSE;
} }
BOOL WINAPI SQLRemoveDriverW(LPCWSTR lpszDriver, BOOL fRemoveDSN, BOOL WINAPI SQLRemoveDriverW(LPCWSTR drivername, BOOL remove_dsn, LPDWORD usage_count)
LPDWORD lpdwUsageCount)
{ {
HKEY hkey;
DWORD usagecount = 1;
clear_errors(); clear_errors();
FIXME("%s %d %p\n", debugstr_w(lpszDriver), fRemoveDSN, lpdwUsageCount); TRACE("%s %d %p\n", debugstr_w(drivername), remove_dsn, usage_count);
if (lpdwUsageCount) *lpdwUsageCount = 1;
if (RegOpenKeyW(HKEY_LOCAL_MACHINE, odbcini, &hkey) == ERROR_SUCCESS)
{
HKEY hkeydriver;
if (RegOpenKeyW(hkey, drivername, &hkeydriver) == ERROR_SUCCESS)
{
DWORD size, type;
DWORD count;
size = sizeof(usagecount);
RegGetValueA(hkeydriver, NULL, "UsageCount", RRF_RT_DWORD, &type, &usagecount, &size);
TRACE("Usage count %d\n", usagecount);
count = usagecount - 1;
if (count)
{
if (RegSetValueExA(hkeydriver, "UsageCount", 0, REG_DWORD, (BYTE*)&count, sizeof(count)) != ERROR_SUCCESS)
ERR("Failed to write registry UsageCount key\n");
}
RegCloseKey(hkeydriver);
}
if (usagecount)
usagecount--;
if (!usagecount)
{
if (RegDeleteKeyW(hkey, drivername) != ERROR_SUCCESS)
ERR("Failed to delete registry key: %s\n", debugstr_w(drivername));
if (RegOpenKeyW(hkey, odbcdrivers, &hkeydriver) == ERROR_SUCCESS)
{
if(RegDeleteValueW(hkeydriver, drivername) != ERROR_SUCCESS)
ERR("Failed to delete registry value: %s\n", debugstr_w(drivername));
RegCloseKey(hkeydriver);
}
}
RegCloseKey(hkey);
}
if (usage_count)
*usage_count = usagecount;
return TRUE; return TRUE;
} }
BOOL WINAPI SQLRemoveDriver(LPCSTR lpszDriver, BOOL fRemoveDSN, BOOL WINAPI SQLRemoveDriver(LPCSTR lpszDriver, BOOL fRemoveDSN,
LPDWORD lpdwUsageCount) LPDWORD lpdwUsageCount)
{ {
WCHAR *driver;
BOOL ret;
clear_errors(); clear_errors();
FIXME("%s %d %p\n", debugstr_a(lpszDriver), fRemoveDSN, lpdwUsageCount); TRACE("%s %d %p\n", debugstr_a(lpszDriver), fRemoveDSN, lpdwUsageCount);
if (lpdwUsageCount) *lpdwUsageCount = 1;
return TRUE; driver = SQLInstall_strdup(lpszDriver);
ret = SQLRemoveDriverW(driver, fRemoveDSN, lpdwUsageCount);
HeapFree(GetProcessHeap(), 0, driver);
return ret;
} }
BOOL WINAPI SQLRemoveDriverManager(LPDWORD pdwUsageCount) BOOL WINAPI SQLRemoveDriverManager(LPDWORD pdwUsageCount)
......
...@@ -462,12 +462,12 @@ void test_SQLInstallDriverEx(void) ...@@ -462,12 +462,12 @@ void test_SQLInstallDriverEx(void)
cnt = 100; cnt = 100;
ret = SQLRemoveDriver("WINE ODBC Driver", FALSE, &cnt); ret = SQLRemoveDriver("WINE ODBC Driver", FALSE, &cnt);
ok(ret, "SQLRemoveDriver failed\n"); ok(ret, "SQLRemoveDriver failed\n");
todo_wine ok(cnt == 0, "SQLRemoveDriver failed %d\n", cnt); ok(cnt == 0, "SQLRemoveDriver failed %d\n", cnt);
cnt = 100; cnt = 100;
ret = SQLRemoveDriver("WINE ODBC Driver Path", FALSE, &cnt); ret = SQLRemoveDriver("WINE ODBC Driver Path", FALSE, &cnt);
ok(ret, "SQLRemoveDriver failed\n"); ok(ret, "SQLRemoveDriver failed\n");
todo_wine ok(cnt == 0, "SQLRemoveDriver failed %d\n", cnt); ok(cnt == 0, "SQLRemoveDriver failed %d\n", cnt);
} }
START_TEST(misc) START_TEST(misc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment