[wxPython-dev] Patch for wx/lib/pdfwin.py

Paul McNett p at ulmcnett.com
Tue Jun 5 15:42:56 PDT 2007


Paul McNett wrote:
> Attached is (I believe) a more intelligent discoverer of the =

> latest-installed Acrobat Reader version for use with ActiveX_PDFWindow.
> =

> I tested it on my WinXP / Acrobat 8.0 setup and it worked fine.

Oops, this fixes a potential error if Acrobat can't be found in the =

registry.

Paul
-------------- next part --------------
--- pdfwin.py.old	2007-06-05 15:34:03.000000000 -0700
+++ pdfwin.py	2007-06-05 15:41:34.000000000 -0700
@@ -22,19 +22,25 @@
     global _acroversion
     if _acroversion =3D=3D None:
         import _winreg
-        acrosoft =3D [r'SOFTWARE\Adobe\Acrobat Reader\%version%\InstallPat=
h',
-                    r'SOFTWARE\Adobe\Adobe Acrobat\%version%\InstallPath',]
-            =

-        for regkey in acrosoft:
-            for version in ('7.0', '6.0', '5.0', '4.0'):
+        adobesoft =3D _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Softwa=
re\Adobe')
+        acrokeys, acroversions =3D [], []
+        for index in range(_winreg.QueryInfoKey(adobesoft)[0]):
+            key =3D _winreg.EnumKey(adobesoft, index)
+            if "acrobat" in key.lower():
+                acrokeys.append(_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE=
, 'Software\\Adobe\\%s' % key))
+        for acrokey in acrokeys:
+            print acrokey
+            for index in range(_winreg.QueryInfoKey(acrokey)[0]):
+                key =3D _winreg.EnumKey(acrokey, index)
                 try:
-                    path =3D _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE,
-                                              regkey.replace('%version%', =
version))
-                    _acroversion =3D version
-                    break
+                    acroversions.append(float(key))
                 except:
-                    continue
+                    pass
+        acroversions.sort(reverse=3DTrue)
+        if acroversions:
+            _acroversion =3D acroversions[0]
     return _acroversion
+            =

 =

 #----------------------------------------------------------------------
 =

@@ -54,7 +60,7 @@
 # Co-ordinates passed as parameters are in points (1/72 inch).
 =

 =

-if get_acroversion() >=3D '7.0':
+if get_acroversion() >=3D 7.0:
 =

     from wx.lib.activexwrapper import MakeActiveXClass
     import win32com.client.gencache


More information about the wxpython-dev mailing list