def get_steam_path():
"""Get the path for Steam from the Steam process. If that fails, it uses the registry on Windows.
Returns:
str: The path to Steam. If the path could not be found, the current directory is returned instead (os.curdir)
"""
if psutil:
for pid in psutil.process_iter():
try:
if pid.name().lower() == 'steam.exe' or pid.name().lower() == 'steam':
return os.path.dirname(pid.exe())
except psutil.Error:
logger.exception("Could not get Steam path from its process.")
if winreg:
try:
reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Software\Valve\Steam')
return os.path.normpath(winreg.QueryValueEx(reg_key, r'SteamPath')[0])
except WindowsError:
logger.exception("Could not query registry for Steam path")
return os.curdir
评论列表
文章目录