From f1950ef831ae41c7d6fb41eabd11a1e88dcb8569 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 20 Jun 2006 02:55:36 +0000 Subject: [PATCH] * src/Mime/_WinMime.py: Get application description from registry svn: r6921 --- ChangeLog | 3 +++ src/Mime/_WinMime.py | 35 +++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2b7949ad..73926c95c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2006-06-19 Brian Matherly + * src/Mime/_WinMime.py: Get application description from registry + 2006-06-19 Don Allingham * src/DataViews/_Relationship.py: handle person set to None * src/ViewManger.py: try tabs on the side diff --git a/src/Mime/_WinMime.py b/src/Mime/_WinMime.py index 475ecbfdf..26bf9e226 100644 --- a/src/Mime/_WinMime.py +++ b/src/Mime/_WinMime.py @@ -51,20 +51,39 @@ def get_application(type): extension = _get_extension(type) progId = _get_prog_id(extension) - if progId: - # Find the application associated with this program ID - aReg = ConnectRegistry(None,HKEY_CLASSES_ROOT) - subkey = OpenKey(aReg, "%s\shell\open\command" % progId) + if not progId: + return None + + # Find the application associated with this program ID + aReg = ConnectRegistry(None,HKEY_CLASSES_ROOT) + subkey = OpenKey(aReg, "%s\shell\open\command" % progId) + if subkey: n,command,type = EnumValue(subkey, 0) if type == REG_EXPAND_SZ: command = command.replace( '%SystemRoot%', os.getenv('SystemRoot') ) + CloseKey(aReg) + else: + return None + CloseKey(subkey) - # TODO: figure out how to get a description of the application - # use that instead of progId - return (command,progId) + # Find a friendly name for the application + if command.startswith('"'): + app = command.split('"')[1] + else: + app = command.split()[0] + + hcu = ConnectRegistry(None,HKEY_CURRENT_USER) + subkey = OpenKey(hcu, "Software\Microsoft\Windows\ShellNoRoam\MUICache") + desc = None + if subkey: + desc,type = QueryValueEx(subkey, app) + CloseKey(subkey) + else: + desc = progId + CloseKey(hcu) - return None + return (command,desc) def get_description(mime_type): """Returns the description of the specfied mime type"""