Seems good enough
The main thing is that it does what you want, and that the code is clean enough so you can add functions later.
Forged Alliance Forever Forums
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
def showsupcomfapath(self):
import errno
import win32com.client
import _winreg
shell = win32com.client.Dispatch('WScript.Shell')
proc_arch = shell.ExpandEnvironmentStrings(r'%PROCESSOR_ARCHITECTURE%').lower()
if proc_arch == 'x86':
arch_keys = {0}
elif proc_arch == 'amd64':
arch_keys = {_winreg.KEY_WOW64_32KEY, _winreg.KEY_WOW64_64KEY}
else:
raise Exception("Unhandled arch: %s" % arch)
for arch_key in arch_keys:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{31D95937-B237-405D-920C-A3EF4E482395}", 0, _winreg.KEY_READ | arch_key)
for i in xrange(0, _winreg.QueryInfoKey(key)[0]-1):
skey_name = _winreg.EnumKey(key, i)
skey = _winreg.OpenKey(key, skey_name)
try:
print _winreg.QueryValueEx(skey, 'InstallLocation')[0]
except OSError as e:
if e.errno == errno.ENOENT:
# DisplayName doesn't exist in this skey
pass
finally:
skey.Close()
Nossa wrote:I've never played GPG or even heard of FA until FAF started blowing up.
Users browsing this forum: No registered users and 1 guest