diff --git a/Languages/IronPython/IronPython.Modules/_winreg.cs b/Languages/IronPython/IronPython.Modules/_winreg.cs index 10a667e948..fce8db5316 100644 --- a/Languages/IronPython/IronPython.Modules/_winreg.cs +++ b/Languages/IronPython/IronPython.Modules/_winreg.cs @@ -265,6 +265,7 @@ public static PythonTuple EnumValue(object key, int index) { } private static void QueryValueExImpl(SafeRegistryHandle handle, string valueName, out int valueKind, out object value) { + valueName = valueName ?? ""; // it looks like RegQueryValueEx can fail with null, use empty string instead valueKind = 0; int dwRet; byte[] data = new byte[128]; @@ -278,6 +279,13 @@ private static void QueryValueExImpl(SafeRegistryHandle handle, string valueName dwRet = RegQueryValueEx(handle, valueName, IntPtr.Zero, out valueKind, data, ref length); } + if (dwRet == PythonExceptions._WindowsError.ERROR_FILE_NOT_FOUND) { + throw PythonExceptions.CreateThrowable(PythonExceptions.WindowsError, PythonExceptions._WindowsError.ERROR_FILE_NOT_FOUND, "The system cannot find the file specified"); + } + if (dwRet != ERROR_SUCCESS) { + throw PythonExceptions.CreateThrowable(PythonExceptions.WindowsError, dwRet); + } + // convert the result into a Python object switch (valueKind) {