-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpath.py
57 lines (39 loc) · 1.39 KB
/
path.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!usr/bin/env python3
# File: path.py
# Path file
import os
from winreg import HKEY_CURRENT_USER, OpenKey, QueryValueEx
SteamGamesPath = None # Steam Common Directory
DocumentsPath = None # Windows My Documents Directory
GamesPath = None # Windows My Games Directory
LocalAppPath = None # Windows Local Data Directory
UserName = None # User Name
try:
key = OpenKey(HKEY_CURRENT_USER, 'Software\\Valve\\Steam')
SteamPath = QueryValueEx(key, 'SteamPath') [0]
SteamGamesPath = os.path.normcase(os.path.join(SteamPath, 'steamapps', 'common'))
except WindowsError:
pass
try:
key = OpenKey(HKEY_CURRENT_USER, 'Volatile Environment')
UserPath = QueryValueEx(key, 'USERPROFILE') [0]
DocumentsPath = os.path.normcase(os.path.join(UserPath, 'Documents'))
except WindowsError:
pass
try:
key = OpenKey(HKEY_CURRENT_USER, 'Volatile Environment')
UserPath = QueryValueEx(key, 'USERPROFILE') [0]
GamesPath = os.path.normcase(os.path.join(UserPath, 'Saved Games'))
except WindowsError:
pass
try:
key = OpenKey(HKEY_CURRENT_USER, 'Volatile Environment')
LocalApp = QueryValueEx(key, 'LOCALAPPDATA') [0]
LocalAppPath = os.path.normcase(os.path.join(LocalApp))
except WindowsError:
pass
try:
key = OpenKey(HKEY_CURRENT_USER, 'Volatile Environment')
UserName = QueryValueEx(key, 'USERNAME') [0]
except WindowsError:
pass