[v3 PATCH 2/2] odbccp32: Implement SQLRemoveTranslator/W

Huw Davies huw at codeweavers.com
Wed Apr 5 03:41:42 CDT 2017


On Wed, Apr 05, 2017 at 01:29:21AM +0000, Alistair Leslie-Hughes wrote:
> diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c
> index 7b2f020bbe..4e00f2a29f 100644
> --- a/dlls/odbccp32/odbccp32.c
> +++ b/dlls/odbccp32/odbccp32.c
> @@ -1229,20 +1229,75 @@ BOOL WINAPI SQLRemoveDSNFromIni(LPCSTR lpszDSN)
>      return FALSE;
>  }
>  
> -BOOL WINAPI SQLRemoveTranslatorW(LPCWSTR lpszTranslator, LPDWORD lpdwUsageCount)
> +BOOL WINAPI SQLRemoveTranslatorW(const WCHAR *translator, DWORD *usage_count)
>  {
> +    HKEY hkey;
> +    DWORD usagecount = 1;
> +
>      clear_errors();
> -    FIXME("%s %p\n", debugstr_w(lpszTranslator), lpdwUsageCount);
> -    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
> -    return FALSE;
> +    TRACE("%s %p\n", debugstr_w(translator), usage_count);
> +
> +    if (RegOpenKeyW(HKEY_LOCAL_MACHINE, odbcini, &hkey) == ERROR_SUCCESS)
> +    {
> +        HKEY hkeydriver;
> +
> +        if (RegOpenKeyW(hkey, translator, &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, translator) != ERROR_SUCCESS)
> +                ERR("Failed to delete registry key: %s\n", debugstr_w(translator));
> +
> +            if (RegOpenKeyW(hkey, odbctranslators, &hkeydriver) == ERROR_SUCCESS)
> +            {
> +                if(RegDeleteValueW(hkeydriver, translator) != ERROR_SUCCESS)
> +                    ERR("Failed to delete registry value: %s\n", debugstr_w(translator));
> +
> +                RegCloseKey(hkeydriver);
> +            }
> +        }
> +
> +        RegCloseKey(hkey);
> +    }
> +
> +    if (usage_count)
> +        *usage_count = 0;

Should this really always be zero?

Huw.



More information about the wine-devel mailing list