This commit is contained in:
恍兮惚兮 2024-05-03 20:24:17 +08:00
parent 30c646ddd0
commit f10c785d97
2 changed files with 32 additions and 5 deletions

View File

@ -1,12 +1,13 @@
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QFont
import sys, windows
import platform, os
if __name__ == "__main__":
dirname = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.chdir(dirname)
windows.addenvpath("./LunaTranslator/runtime/") # win7 no vcredist2015
windows.loadlibrary(
"./LunaTranslator/runtime/PyQt5/Qt5/bin/Qt5Core.dll"
) # win7 no vcredist2015
for p in (
"./userconfig/memory",
"./userconfig/memory",
@ -36,6 +37,11 @@ if __name__ == "__main__":
import gobject
gobject.overridepathexists()
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QFont
QApplication.addLibraryPath(
"./LunaTranslator/runtime/PyQt5/Qt5/plugins"
) # 中文字符下不能自动加载

View File

@ -25,7 +25,7 @@ from ctypes import (
sizeof,
byref,
)
import ctypes
import ctypes, os
from traceback import print_exc
from ctypes.wintypes import (
RECT,
@ -949,3 +949,24 @@ _SetPropW.restype = BOOL
def SetProp(hwnd, string, hdata):
return _SetPropW(hwnd, string, hdata)
_GetEnvironmentVariableW = _kernel32.GetEnvironmentVariableW
_GetEnvironmentVariableW.argtypes = c_wchar_p, c_wchar_p, DWORD
_SetEnvironmentVariableW = _kernel32.SetEnvironmentVariableW
_SetEnvironmentVariableW.argtypes = LPCWSTR, LPCWSTR
def addenvpath(path):
path = os.path.abspath(path)
env = create_unicode_buffer(65535)
_GetEnvironmentVariableW("PATH", env, 65535)
_SetEnvironmentVariableW("PATH", env.value + ";" + path)
_LoadLibraryW = _kernel32.LoadLibraryW
_LoadLibraryW.argtypes = (LPCWSTR,)
def loadlibrary(path):
_LoadLibraryW(path)