[vlc-devel] commit: python-ctypes: improve win32 initialization (contrib from <mmuellen @gmx.de>) (Olivier Aubert )

git version control git at videolan.org
Mon Aug 10 10:09:11 CEST 2009


vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Mon Aug 10 10:07:00 2009 +0200| [e23c4d69faf2003599f01b366fc64e1c006c34ea] | committer: Olivier Aubert 

python-ctypes: improve win32 initialization (contrib from <mmuellen at gmx.de>)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e23c4d69faf2003599f01b366fc64e1c006c34ea
---

 bindings/python-ctypes/header.py |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/bindings/python-ctypes/header.py b/bindings/python-ctypes/header.py
index e81c6f8..4f4c870 100755
--- a/bindings/python-ctypes/header.py
+++ b/bindings/python-ctypes/header.py
@@ -46,11 +46,26 @@ elif sys.platform == 'win32':
     plugin_path=None
     path=ctypes.util.find_library('libvlc.dll')
     if path is None:
-        # Try a standard location.
-        p='c:\\Program Files\\VideoLAN\\VLC\\libvlc.dll'
-        if os.path.exists(p):
-            plugin_path=os.path.dirname(p)
-            os.chdir(plugin_path)
+        # Try to use registry settings
+        import _winreg
+        plugin_path_found = None
+        subkey, name = 'Software\\VideoLAN\\VLC','InstallDir'
+        for hkey in _winreg.HKEY_LOCAL_MACHINE, _winreg.HKEY_CURRENT_USER:
+            try:
+                reg = _winreg.OpenKey(hkey, subkey)
+                plugin_path_found, type_id = _winreg.QueryValueEx(reg, name)
+                _winreg.CloseKey(reg)
+                break
+            except _winreg.error:
+                pass
+        if plugin_path_found:
+            plugin_path = plugin_path_found
+        else:
+            # Try a standard location.
+            p='c:\\Program Files\\VideoLAN\\VLC\\libvlc.dll'
+            if os.path.exists(p):
+                plugin_path=os.path.dirname(p)
+        os.chdir(plugin_path)
         # If chdir failed, this will not work and raise an exception
         path='libvlc.dll'
     else:




More information about the vlc-devel mailing list