-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Currently we load the .osdev modules by simply calling LoadLibraryA() (with the path found purely by searching the filesystem).
For example, openscan-mm-adapter sets the module search path to . and $MICROMANAGER_PATH. OpenScanLib finds .osdev files in these paths, then loads them with their explicit path.
In the MMStudio case, the current directory is the Micro-Manager folder, where the necessary DLLs are usually located, so it works. Even if the .osdev depends on vendor.dll, LoadLibraryA() searches the current directory (as well as the executable's directory), so vendor.dll will load correctly.
When using from other systems (e.g., pymmcore-plus), this is not always the case. We should change to:
LoadLibraryExA(
dllpath,
NULL,
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS
)That way, all DLLs required by the .osdev can be located in the same directory as the .osdev. For example, pymmcore users will no longer need to chdir to the MM folder and can instead just set MICROMANAGER_PATH.
Non-DLL dependencies need to be handled explicitly by the device module. For example the BH_SPC module already searches . and $MICROMANAGER_PATH for its spcm.ini file.
Cc: @gselzer.