Skip to content

Commit

Permalink
fix: Windows DLL proper load
Browse files Browse the repository at this point in the history
  • Loading branch information
RobPasMue committed Nov 6, 2024
1 parent c0b8194 commit 6feee2e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/ansys/tools/installer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,29 @@ def _run_install_python(self, filename):
self.setEnabled(True)


def __restore_windows_dll_load():
"""PyInstaller on Windows may break DLL loading. This function restores it."""
import sys
LOG.debug(f"sys.platform: {sys.platform}")
if sys.platform == "win32":
LOG.debug("Restoring DLL loading on Windows...")
import ctypes
ctypes.windll.kernel32.SetDllDirectoryA(None)


def open_gui():
"""Start the installer as a QT Application."""
import argparse
import ctypes

# Enable logging early
enable_logging()

if os.name == "nt":
import msvcrt

# Restore DLL loading on Windows...
__restore_windows_dll_load()

kernel32 = ctypes.windll.kernel32

Expand Down Expand Up @@ -776,8 +792,6 @@ def open_gui():
sys.stdout = open("CONOUT$", "w")
sys.stderr = open("CONOUT$", "w")

enable_logging()

app = QtWidgets.QApplication(sys.argv)
window = AnsysPythonInstaller()

Expand Down

0 comments on commit 6feee2e

Please sign in to comment.