Skip to content

Allow device modules' dependencies to be found in the same directory #27

Description

@marktsuchida

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions