Files
WQ_GUI/scripts/rthook_add_dll_dirs.py
2026-04-08 15:25:08 +08:00

26 lines
560 B
Python

import os
import sys
def _safe_add(path: str) -> None:
if not path or not os.path.isdir(path):
return
try:
if hasattr(os, "add_dll_directory"):
os.add_dll_directory(path)
except Exception:
pass
try:
os.environ["PATH"] = path + os.pathsep + os.environ.get("PATH", "")
except Exception:
pass
# PyInstaller onefile 解包目录
base = getattr(sys, "_MEIPASS", None)
if base:
_safe_add(base)
_safe_add(os.path.join(base, "lib-dynload"))
_safe_add(os.path.join(base, "DLLs"))