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 3477 9ec5ecf9f589
parent 3476 46a7aac382ef
child 3478 c04c6db09eff
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('"', '')