setupapi: Fix return behaviour when the device key doesn't exist.
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 9176554..73a67ee 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -3728,8 +3728,13 @@
WCHAR devId[10];
sprintfW(devId, fmt, devInfo->devId);
- RegOpenKeyExW(classKey, devId, 0, samDesired, &key);
+ l = RegOpenKeyExW(classKey, devId, 0, samDesired, &key);
RegCloseKey(classKey);
+ if (l)
+ {
+ SetLastError(ERROR_KEY_DOES_NOT_EXIST);
+ return INVALID_HANDLE_VALUE;
+ }
}
return key;
}
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index 3c01f32..df4a407 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -974,7 +974,6 @@
key = pSetupDiOpenDevRegKey(set, &devInfo, DICS_FLAG_GLOBAL, 0,
DIREG_DRV, 0);
/* The software key isn't created by default */
- todo_wine
ok(key == INVALID_HANDLE_VALUE &&
GetLastError() == ERROR_KEY_DOES_NOT_EXIST,
"Expected ERROR_KEY_DOES_NOT_EXIST, got %08x\n", GetLastError());