Files
WQ_GUI/scripts/rthook_add_dll_dirs.py
2026-05-11 17:38:29 +08:00

25 lines
585 B
Python

import os
import sys
def _safe_add(path: str) -> None:
if not path or not os.path.isdir(path):
return
if hasattr(os, "add_dll_directory"):
try:
os.add_dll_directory(path)
return
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"))