skywind3000 / PyStand

:rocket: Python Standalone Deploy Environment !!
MIT License
814 stars 90 forks source link

fix: failed to load python when startup as subprocess. #80

Closed thegoodtgg closed 5 months ago

thegoodtgg commented 5 months ago

According the doc about "LoadLibrary" and "SetDllDirectory", when PyStand not run as sub-process, dll search path not including "runtime" directory, PyStand failed to load python3.dll. Using SetDllDirectory instead of "SetCurrentDirectory" would fix the problem.

thegoodtgg commented 5 months ago

Although, I haven't found any apparent evidences from ms doc. I guess it's related to the way call "CreateProcess" to create PyStand process.

I only found this from LoadLibrary - Remarks

The first directory searched is the directory containing the image file used to create the calling process (for more information, see the CreateProcess function). Doing this allows private dynamic-link library (DLL) files associated with a process to be found without adding the process's installed directory to the PATH environment variable.

However in our situation, python3.dll is loaded from working directory not the application directory.

skywind3000 commented 5 months ago

thanks, but PyStand is using tabs for indentation, while you are using spaces, please keep consistency.