From 58445d26b81ec33c4e37a5c4900db7a9b3323ffd Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Mon, 4 Dec 2023 18:19:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=BE=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E8=B7=AF=E5=BE=84=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?#50?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/util/path.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/app/util/path.py b/app/util/path.py index d87def94..f1748669 100644 --- a/app/util/path.py +++ b/app/util/path.py @@ -23,21 +23,25 @@ def mkdir(path): def wx_path(): - ## 获取当前用户名 - user_home = os.environ.get("USERPROFILE") - ## 找到3ebffe94.ini配置文件 - f = open(user_home + '\\AppData\\Roaming\\Tencent\\WeChat\\All Users\\config\\3ebffe94.ini', encoding='utf-8') - txt = f.read() - f.close() - # 打开Windows注册表 - reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, - "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") - # 获取“我的文档”路径的注册表键值 - documents_path_value = winreg.QueryValueEx(reg_key, "Personal") - # 输出路径 - ##读取文件将路径放到wx_location变量里 - if txt == 'MyDocument:': - wx_location = documents_path_value[0] + '\WeChat Files' - else: - wx_location = txt + "\WeChat Files" - return wx_location + try: + ## 获取当前用户名 + user_home = os.environ.get("USERPROFILE") + ## 找到3ebffe94.ini配置文件 + f = open(user_home + '\\AppData\\Roaming\\Tencent\\WeChat\\All Users\\config\\3ebffe94.ini', encoding='utf-8') + txt = f.read() + f.close() + # 打开Windows注册表 + reg_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, + "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") + # 获取“我的文档”路径的注册表键值 + documents_path_value = winreg.QueryValueEx(reg_key, "Personal") + # 输出路径 + ##读取文件将路径放到wx_location变量里 + if txt == 'MyDocument:': + wx_location = documents_path_value[0] + '\WeChat Files' + else: + wx_location = txt + "\WeChat Files" + return wx_location + except FileNotFoundError: + return '.' +