Skip to content

Commit 5f5a94e

Browse files
committed
调整获取chrome.exe方法次序
1 parent 1d34efb commit 5f5a94e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

DrissionPage/easy_set.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,23 @@ def _get_chrome_path(ini_path: str = None, show_msg: bool = True) -> Union[str,
260260
print('ini文件中', end='')
261261
return str(path)
262262

263+
# -----------从注册表中获取--------------
264+
import winreg
265+
try:
266+
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
267+
r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe',
268+
reserved=0, access=winreg.KEY_READ)
269+
k = winreg.EnumValue(key, 0)
270+
winreg.CloseKey(key)
271+
272+
if show_msg:
273+
print('注册表中', end='')
274+
275+
return k[1]
276+
277+
except FileNotFoundError:
278+
pass
279+
263280
# -----------从系统路径中获取--------------
264281
paths = popen('set path').read().lower()
265282
r = RE_SEARCH(r'[^;]*chrome[^;]*', paths)
@@ -285,23 +302,6 @@ def _get_chrome_path(ini_path: str = None, show_msg: bool = True) -> Union[str,
285302
except OSError:
286303
pass
287304

288-
# -----------从注册表中获取--------------
289-
import winreg
290-
try:
291-
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
292-
r'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe',
293-
reserved=0, access=winreg.KEY_READ)
294-
k = winreg.EnumValue(key, 0)
295-
winreg.CloseKey(key)
296-
297-
if show_msg:
298-
print('注册表中', end='')
299-
300-
return k[1]
301-
302-
except FileNotFoundError:
303-
return
304-
305305

306306
def _get_chrome_version(path: str) -> Union[str, None]:
307307
"""根据文件路径获取版本号 \n

0 commit comments

Comments
 (0)