- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
- 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) {
- SET_FAIL(ret, "RegOpenKeyEx() failed");
+ if ((result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
+ 0, KEY_QUERY_VALUE, &key)) != ERROR_SUCCESS) {
+ /* It's possible for this key to not exist if there are no serial ports
+ * at all. In that case we're done. Return a failure for any other error. */
+ if (result != ERROR_FILE_NOT_FOUND) {
+ SetLastError(result);
+ SET_FAIL(ret, "RegOpenKeyEx() failed");
+ }