Skip to content

Add DLL path during loading - #28

Merged
marktsuchida merged 3 commits into
openscan-lsm:mainfrom
gselzer:load-from-dll-dir
Jul 16, 2026
Merged

Add DLL path during loading#28
marktsuchida merged 3 commits into
openscan-lsm:mainfrom
gselzer:load-from-dll-dir

Conversation

@gselzer

@gselzer gselzer commented May 15, 2026

Copy link
Copy Markdown
Member

This allows DLL dependencies to be loaded from the same directory as the DLL itself. Very useful for usage within pymmcore-plus contexts.

@gselzer

gselzer commented May 15, 2026

Copy link
Copy Markdown
Member Author

Should close #27 . I tested locally, but would be good if you could test as well @marktsuchida

@marktsuchida

Copy link
Copy Markdown
Member

Here's the missing info that could have led to a quicker merge if provided :)

The .osdev is loaded by absolute path before and after this change; transitive dependencies of the .osdev are searched for in the following locations, in order:

Before this PR:

  • The directory of the .exe
  • The System32 directory
  • The 16-bit System directory (who cares?)
  • The Windows directory
  • The current working directory
  • Directories in %Path%

After this PR:

  • The directory of the .osdev
  • The directory of the .exe
  • User directories added by AddDllDirectory/SetDllDirectory (OpenScanLib itself doesn't)
  • The System32 directory

So this no longer finds dependencies in the current working directory or on %Path%. We are also losing the 16-bit System (who cares?) and Windows dirs.

Now, although we have generally relied on either CWD or %Path% to load transitive dependencies, the actual use cases have been limited to the following:

  • NI DAQ: nicaiu.dll is installed in System32 (very old-fashioned, but it is what it is), so unaffected
  • NI FPGA: similar, System32
  • BH SPC: spcm64.dll is practically always copied into the Micro-Manager folder, where the .osdev is also located
  • Test device modules: no transitive deps

So yes, we can do this, but we must note that putting C:\Program Files (x86)\BH\SPCM\DLL in %Path% will no longer work for BH SPC. This may surprise someone who is familiar with the default DLL search order.

@marktsuchida
marktsuchida merged commit 2045fb5 into openscan-lsm:main Jul 16, 2026
@gselzer

gselzer commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

@marktsuchida thanks for digging! Do you think it would be prudent to put this information (at least the current paths being searched) as comments within the file?

@marktsuchida

Copy link
Copy Markdown
Member

@gselzer actually good to put in the readme

@marktsuchida

Copy link
Copy Markdown
Member

And in the docs for OSc_SetDeviceModuleSearchPaths().

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants