Acorn
Acorn

Reputation: 50497

Avoiding having to put DLLs in CWD

Is it possible to avoid having to put DLLs in the same directory as the scripts using them?

I would like to be able to put a DLL in one place and have it reachable by any script.

ctypes.CDLL() seems to only find DLLs if they are in the CWD. Putting them somewhere in sys.path, or in System32 doesn't work.

Specifically I'm trying to get UniCurses to find pdcurses.dll without it being in the the CWD.

Upvotes: 2

Views: 580

Answers (1)

PaulMcG
PaulMcG

Reputation: 63709

Try:

pdcurses_path = ctypes.util.find_library('pdcurses.dll')
if pdcurses_path:
    pdcurses = ctypes.CDLL(pdcurses_path)
else:
    raise ImportError("could not locate pdcurses.dll library")

Upvotes: 2

Related Questions