Detlef Riekenberg wine.dev@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.