winspool: [3/4] Implement AddMonitor

Alexandre Julliard julliard at winehq.org
Tue Apr 11 07:24:28 CDT 2006


Detlef Riekenberg <wine.dev at web.de> writes:

> +    if (RegOpenKeyExW(hroot, mi2w->pName, 0, KEY_READ, &hentry) == ERROR_SUCCESS) {
> +        TRACE("monitor %s already exists\n", debugstr_w(mi2w->pName));
> +        /* NT: ERROR_PRINT_MONITOR_ALREADY_INSTALLED (3006)
> +           9x: ERROR_ALREADY_EXISTS (183) */
> +        SetLastError(ERROR_PRINT_MONITOR_ALREADY_INSTALLED);
> +        goto addmW_cleanup;
> +    }
> +    else
> +    {
> +        if(RegCreateKeyW(hroot,  mi2w->pName, &hentry) == ERROR_SUCCESS) {
> +           INT len;
> +           len = (lstrlenW(mi2w->pDLLName) +1) * sizeof(WCHAR);
> +           res = (RegSetValueExW(hentry, DriverW, 0,
> +                  REG_SZ, (LPBYTE) mi2w->pDLLName, len) == ERROR_SUCCESS);
> +        }
> +    }

There's a race here, you should use RegCreateKeyExW and check the
returned disposition.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list