diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c index ffb5fad1bfd..4a852da18ba 100644 --- a/dlls/setupapi/devinst.c +++ b/dlls/setupapi/devinst.c @@ -3125,7 +3125,9 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyA( LONG l = RegQueryValueExA(devInfo->key, PropertyMap[Property].nameA, NULL, PropertyRegDataType, PropertyBuffer, &size); - if (l == ERROR_MORE_DATA || !PropertyBufferSize) + if (l == ERROR_FILE_NOT_FOUND) + SetLastError(ERROR_INVALID_DATA); + else if (l == ERROR_MORE_DATA || !PropertyBufferSize) SetLastError(ERROR_INSUFFICIENT_BUFFER); else if (!l) ret = TRUE; @@ -3186,7 +3188,9 @@ BOOL WINAPI SetupDiGetDeviceRegistryPropertyW( LONG l = RegQueryValueExW(devInfo->key, PropertyMap[Property].nameW, NULL, PropertyRegDataType, PropertyBuffer, &size); - if (l == ERROR_MORE_DATA || !PropertyBufferSize) + if (l == ERROR_FILE_NOT_FOUND) + SetLastError(ERROR_INVALID_DATA); + else if (l == ERROR_MORE_DATA || !PropertyBufferSize) SetLastError(ERROR_INSUFFICIENT_BUFFER); else if (!l) ret = TRUE; diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c index 6ca0e928b90..4df00b1855f 100644 --- a/dlls/setupapi/tests/devinst.c +++ b/dlls/setupapi/tests/devinst.c @@ -1051,6 +1051,10 @@ static void testDeviceRegistryPropertyA(void) ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_FRIENDLYNAME, NULL, (PBYTE)buf, buflen, &size); todo_wine + ok(!ret && GetLastError() == ERROR_INVALID_DATA, + "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); + ret = pSetupDiGetDeviceRegistryPropertyA(set, &devInfo, SPDRP_HARDWAREID, + NULL, NULL, 0, &size); ok(!ret && GetLastError() == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); pSetupDiDestroyDeviceInfoList(set); @@ -1156,6 +1160,10 @@ static void testDeviceRegistryPropertyW(void) ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_FRIENDLYNAME, NULL, (PBYTE)buf, buflen, &size); todo_wine + ok(!ret && GetLastError() == ERROR_INVALID_DATA, + "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); + ret = pSetupDiGetDeviceRegistryPropertyW(set, &devInfo, SPDRP_HARDWAREID, + NULL, NULL, 0, &size); ok(!ret && GetLastError() == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got %08x\n", GetLastError()); pSetupDiDestroyDeviceInfoList(set);