Skip to content

Instantly share code, notes, and snippets.

@BuongiornoTexas
Created January 15, 2022 21:58
Show Gist options
  • Save BuongiornoTexas/53882852369a1fa4e80e031209e32f46 to your computer and use it in GitHub Desktop.
Save BuongiornoTexas/53882852369a1fa4e80e031209e32f46 to your computer and use it in GitHub Desktop.
Steam registry fragments - Windows python methods for getting Steam user data.
# utilities for extracting Steam parameters from the windows registry.
# Replaced in rsrtools with vdf processing routines.
# Not used. Delete in later version.
def steam_registry_users() -> List[str]:
"""Return list[str] of Steam account ids found in the registry."""
ret_val = list()
try:
with winreg.OpenKey(
winreg.HKEY_CURRENT_USER, r"Software\Valve\Steam\Users"
) as sub_key:
i = 0
while True:
try:
account_id = winreg.EnumKey(sub_key, i)
except OSError:
break
ret_val.append(account_id)
i = i + 1
except OSError:
pass
return ret_val
# replace this with a function that returns a dictionary of Steam user descriptions
# dict[steam_account_id, <PersonaName> (account_name), most recently logged in account]
def steam_active_user() -> int:
"""Return Steam active user as an integer, or 0 for no active user."""
ret_val = 0
try:
with winreg.OpenKey(
winreg.HKEY_CURRENT_USER, r"Software\Valve\Steam\ActiveProcess"
) as sub_key:
ret_val, _ = winreg.QueryValueEx(sub_key, "ActiveUser")
except OSError:
pass
return ret_val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment