/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/win32utils.py

  • Committer: Martin Pool
  • Date: 2007-08-21 03:40:50 UTC
  • mfrom: (2736 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2737.
  • Revision ID: mbp@sourcefrog.net-20070821034050-gcppw53kbcm2gwgd
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
287
287
            expanded_file_list += glob_files
288
288
            
289
289
    return [elem.replace(u'\\', u'/') for elem in expanded_file_list] 
 
290
 
 
291
 
 
292
def get_app_path(appname):
 
293
    """Look up in Windows registry for full path to application executable.
 
294
    Typicaly, applications create subkey with their basename
 
295
    in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
 
296
 
 
297
    :param  appname:    name of application (if no filename extension
 
298
                        is specified, .exe used)
 
299
    :return:    full path to aplication executable from registry,
 
300
                or appname itself if nothing found.
 
301
    """
 
302
    import _winreg
 
303
    try:
 
304
        hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
 
305
                               r'SOFTWARE\Microsoft\Windows'
 
306
                               r'\CurrentVersion\App Paths')
 
307
    except EnvironmentError:
 
308
        return appname
 
309
 
 
310
    basename = appname
 
311
    if not os.path.splitext(basename)[1]:
 
312
        basename = appname + '.exe'
 
313
    try:
 
314
        try:
 
315
            fullpath = _winreg.QueryValue(hkey, basename)
 
316
        except WindowsError:
 
317
            fullpath = appname
 
318
    finally:
 
319
        _winreg.CloseKey(hkey)
 
320
 
 
321
    return fullpath