From c3dda0d901ee9c31c0b955ae9fb9b85079ad1cd4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 27 Feb 2015 14:58:40 +0530 Subject: [PATCH] Nicer error message when running calibre on old windows --- src/calibre/utils/winreg/lib.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/winreg/lib.py b/src/calibre/utils/winreg/lib.py index aa301dcf58..0a23ad4ac8 100644 --- a/src/calibre/utils/winreg/lib.py +++ b/src/calibre/utils/winreg/lib.py @@ -125,9 +125,13 @@ def convert_registry_data(raw, size, dtype): return ctypes.cast(raw, ctypes.POINTER(types.QWORD)).contents.value raise ValueError('Unsupported data type: %r' % dtype) -RegSetKeyValue = cwrap( - 'RegSetKeyValueW', LONG, a('key', HKEY), a('sub_key', LPCWSTR, None), a('name', LPCWSTR, None), - a('dtype', DWORD, winreg.REG_SZ), a('data', LPCVOID, None), a('size', DWORD)) +try: + RegSetKeyValue = cwrap( + 'RegSetKeyValueW', LONG, a('key', HKEY), a('sub_key', LPCWSTR, None), a('name', LPCWSTR, None), + a('dtype', DWORD, winreg.REG_SZ), a('data', LPCVOID, None), a('size', DWORD)) +except Exception: + raise RuntimeError('calibre requires Windows Vista or newer to run, the last version of calibre' + ' that could run on Windows XP is version 1.48, available from: http://download.calibre-ebook.com/') def delete_value_errcheck(result, func, args): if result == winerror.ERROR_FILE_NOT_FOUND: