IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 23 May 2022 18:11:31 +0200
changeset 3494 435259844a64
parent 3493 ff25207ec303
child 3495 f422d3d71f89
IDE/Windows: Find Inkscape binary even if Inkscape was installed for current user only.
docutil/docsvg.py
--- a/docutil/docsvg.py	Mon May 23 18:10:13 2022 +0200
+++ b/docutil/docsvg.py	Mon May 23 18:11:31 2022 +0200
@@ -33,15 +33,19 @@
     if wx.Platform == '__WXMSW__':
         from six.moves import winreg
         inkcmd = None
-        try:
-            inkcmd = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
-                                           'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
-        except OSError:
+        tries = [(winreg.HKEY_LOCAL_MACHINE, 'Software\\Classes\\svgfile\\shell\\Inkscape\\command'),
+                 (winreg.HKEY_LOCAL_MACHINE, 'Software\\Classes\\inkscape.svg\\shell\\open\\command'),
+                 (winreg.HKEY_CURRENT_USER, 'Software\\Classes\\inkscape.svg\\shell\\open\\command')]
+
+        for subreg, key in tries:
             try:
-                inkcmd = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
-                                               'Software\\Classes\\inkscape.svg\\shell\\open\\command')
+                inkcmd = winreg.QueryValue(subreg, key)
+                break;
             except OSError:
-                return None
+                pass
+
+        if inkcmd is None:
+            return None
 
         return inkcmd.replace('"%1"', '').strip().replace('"', '')