common.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pyjam 作者: 10se1ucgo 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号