How to find path to a loaded DLL on Windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to find path to a loaded DLL on Windows

Wayne Johnston
We have an application that searches around for a DLL and loads it.  Since the DLL should be readily loadable (like the many other DLLs) without us looking for it, I'd like to remove the code that searches for the file.  That's easy.  But it would be nice to keep our code which prints out attributes of the file in case of a version problem.  Once the magic DLL-loading code runs, I don't see how to know for instance the full path to the file it loaded.  Or in advance to know the file that would be loaded.  Can it be done?

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to find path to a loaded DLL on Windows

Wayne Johnston
A colleague pointed me to this, which works:
OSHmodule>>#getModuleFileName:cbFileName:

It can be used for instance like this:

pathForDLL: aString
"Answer the path to the aString DLL,
or an AbtError if the DLL cannot be found"

| rc modHandle modName |
(modHandle := OSHmodule loadLibrary: aString) reference == 0
ifTrue: [ ^AbtError errorText: ('Cannot load %1' bindWith: aString) ].
modName := String new: 500.
^(modHandle getModuleFileName: modName cbFileName: modName size) == 0
ifTrue: [ AbtError errorText: ('Unable to determine filename for %1' bindWith: aString) ]
ifFalse: [ modName trimNull ]

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.