Using the Windows "embedded" distribution of Python

eryk sun eryksun at gmail.com
Wed Sep 28 16:49:50 EDT 2016


On Wed, Sep 28, 2016 at 2:35 PM, Paul  Moore <p.f.moore at gmail.com> wrote:
> So I thought I'd try SetDllDirectory. That works for python36.dll, but if I load
> python3.dll, it can't find Py_Main - the export shows as "(forwarded to
> python36.Py_Main)", maybe the forwarding doesn't handle SetDllDirectory?

It works for me. Are you calling SetDllDirectory with the
fully-qualified path? If not it's relative to the working directory,
which isn't necessarily (generally is not) the application directory,
in which case delay-loading python36.dll will fail. You can create the
fully-qualified path from the application path, i.e.
GetModuleFileNameW(NULL, ...).

That said, I prefer using LoadLibraryExW(absolute_path_to_python3,
NULL, LOAD_WITH_ALTERED_SEARCH_PATH). The alternate search substitutes
the DLL's directory for the application directory when loading
dependent DLLs, which allows loading python36.dll and vcruntime140.dll
without having to modify the DLL search path of the entire process.



More information about the Python-list mailing list